From f1fafb2c6f5f90664fbb9b672fbc8cf0da39e79b Mon Sep 17 00:00:00 2001 From: kazuho cryer-shinozuka Date: Sat, 4 May 2024 22:32:49 +0900 Subject: [PATCH] feat(aws-ec2): construct for EC2 Instance Connect Endpoint (#22) Co-authored-by: Thorsten Hoeger --- API.md | 492 ++++++++ src/aws-ec2/README.md | 78 ++ src/aws-ec2/index.ts | 1 + src/aws-ec2/instance-connect-endpoint.ts | 144 +++ src/index.ts | 3 +- .../aws-ec2/instance-connect-endpoint.test.ts | 74 ++ .../integ.instance-connect-endpoint.ts | 49 + ...efaultTestDeployAssert284B1FD7.assets.json | 19 + ...aultTestDeployAssert284B1FD7.template.json | 36 + .../InstanceConnectEndpointStack.assets.json | 32 + ...InstanceConnectEndpointStack.template.json | 716 +++++++++++ .../__entrypoint__.js | 1 + .../index.js | 1 + .../cdk.out | 1 + .../integ.json | 12 + .../manifest.json | 317 +++++ .../tree.json | 1098 +++++++++++++++++ 17 files changed, 3073 insertions(+), 1 deletion(-) create mode 100644 src/aws-ec2/README.md create mode 100644 src/aws-ec2/index.ts create mode 100644 src/aws-ec2/instance-connect-endpoint.ts create mode 100644 test/aws-ec2/instance-connect-endpoint.test.ts create mode 100644 test/aws-ec2/integ.instance-connect-endpoint.ts create mode 100644 test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/InstanceConnectEndpointDefaultTestDeployAssert284B1FD7.assets.json create mode 100644 test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/InstanceConnectEndpointDefaultTestDeployAssert284B1FD7.template.json create mode 100644 test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/InstanceConnectEndpointStack.assets.json create mode 100644 test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/InstanceConnectEndpointStack.template.json create mode 100644 test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/asset.dd5711540f04e06aa955d7f4862fc04e8cdea464cb590dae91ed2976bb78098e/__entrypoint__.js create mode 100644 test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/asset.dd5711540f04e06aa955d7f4862fc04e8cdea464cb590dae91ed2976bb78098e/index.js create mode 100644 test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/cdk.out create mode 100644 test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/integ.json create mode 100644 test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/manifest.json create mode 100644 test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/tree.json diff --git a/API.md b/API.md index 0d6d892..84af487 100644 --- a/API.md +++ b/API.md @@ -143,6 +143,287 @@ The S3 bucket that stores the cost report. --- +### InstanceConnectEndpoint + +- *Implements:* @open-constructs/aws-cdk.aws_ec2.IInstanceConnectEndpoint + +Represents an EC2 Instance Connect Endpoint construct in AWS CDK. + +*Example* + +```typescript +declare const securityGroups: aws_ec2.ISecurityGroup[]; +declare const vpc: aws_ec2.IVpc; + +const instanceConnectEndpoint = new InstanceConnectEndpoint( + stack, + 'InstanceConnectEndpoint', + { + clientToken: 'my-client-token', + preserveClientIp: true, + securityGroups, + vpc, + }, +); +``` + + +#### Initializers + +```typescript +import { aws_ec2 } from '@open-constructs/aws-cdk' + +new aws_ec2.InstanceConnectEndpoint(scope: Construct, id: string, props: InstanceConnectEndpointProps) +``` + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| scope | constructs.Construct | *No description.* | +| id | string | *No description.* | +| props | @open-constructs/aws-cdk.aws_ec2.InstanceConnectEndpointProps | *No description.* | + +--- + +##### `scope`Required + +- *Type:* constructs.Construct + +--- + +##### `id`Required + +- *Type:* string + +--- + +##### `props`Required + +- *Type:* @open-constructs/aws-cdk.aws_ec2.InstanceConnectEndpointProps + +--- + +#### Methods + +| **Name** | **Description** | +| --- | --- | +| toString | Returns a string representation of this construct. | +| applyRemovalPolicy | Apply the given removal policy to this resource. | + +--- + +##### `toString` + +```typescript +public toString(): string +``` + +Returns a string representation of this construct. + +##### `applyRemovalPolicy` + +```typescript +public applyRemovalPolicy(policy: RemovalPolicy): void +``` + +Apply the given removal policy to this resource. + +The Removal Policy controls what happens to this resource when it stops +being managed by CloudFormation, either because you've removed it from the +CDK application or because you've made a change that requires the resource +to be replaced. + +The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS +account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). + +###### `policy`Required + +- *Type:* aws-cdk-lib.RemovalPolicy + +--- + +#### Static Functions + +| **Name** | **Description** | +| --- | --- | +| isConstruct | Checks if `x` is a construct. | +| isOwnedResource | Returns true if the construct was created by CDK, and false otherwise. | +| isResource | Check whether the given construct is a Resource. | +| fromInstanceConnectEndpointAttributes | Import an existing endpoint to the stack from its attributes. | + +--- + +##### `isConstruct` + +```typescript +import { aws_ec2 } from '@open-constructs/aws-cdk' + +aws_ec2.InstanceConnectEndpoint.isConstruct(x: any) +``` + +Checks if `x` is a construct. + +Use this method instead of `instanceof` to properly detect `Construct` +instances, even when the construct library is symlinked. + +Explanation: in JavaScript, multiple copies of the `constructs` library on +disk are seen as independent, completely different libraries. As a +consequence, the class `Construct` in each copy of the `constructs` library +is seen as a different class, and an instance of one class will not test as +`instanceof` the other class. `npm install` will not create installations +like this, but users may manually symlink construct libraries together or +use a monorepo tool: in those cases, multiple copies of the `constructs` +library can be accidentally installed, and `instanceof` will behave +unpredictably. It is safest to avoid using `instanceof`, and using +this type-testing method instead. + +###### `x`Required + +- *Type:* any + +Any object. + +--- + +##### `isOwnedResource` + +```typescript +import { aws_ec2 } from '@open-constructs/aws-cdk' + +aws_ec2.InstanceConnectEndpoint.isOwnedResource(construct: IConstruct) +``` + +Returns true if the construct was created by CDK, and false otherwise. + +###### `construct`Required + +- *Type:* constructs.IConstruct + +--- + +##### `isResource` + +```typescript +import { aws_ec2 } from '@open-constructs/aws-cdk' + +aws_ec2.InstanceConnectEndpoint.isResource(construct: IConstruct) +``` + +Check whether the given construct is a Resource. + +###### `construct`Required + +- *Type:* constructs.IConstruct + +--- + +##### `fromInstanceConnectEndpointAttributes` + +```typescript +import { aws_ec2 } from '@open-constructs/aws-cdk' + +aws_ec2.InstanceConnectEndpoint.fromInstanceConnectEndpointAttributes(scope: Construct, id: string, attrs: InstanceConnectEndpointAttributes) +``` + +Import an existing endpoint to the stack from its attributes. + +###### `scope`Required + +- *Type:* constructs.Construct + +--- + +###### `id`Required + +- *Type:* string + +--- + +###### `attrs`Required + +- *Type:* @open-constructs/aws-cdk.aws_ec2.InstanceConnectEndpointAttributes + +--- + +#### Properties + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| node | constructs.Node | The tree node. | +| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | +| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | +| connections | aws-cdk-lib.aws_ec2.Connections | The connection object associated with the EC2 Instance Connect Endpoint. | +| instanceConnectEndpointId | string | The ID of the EC2 Instance Connect Endpoint. | + +--- + +##### `node`Required + +```typescript +public readonly node: Node; +``` + +- *Type:* constructs.Node + +The tree node. + +--- + +##### `env`Required + +```typescript +public readonly env: ResourceEnvironment; +``` + +- *Type:* aws-cdk-lib.ResourceEnvironment + +The environment this resource belongs to. + +For resources that are created and managed by the CDK +(generally, those created by creating new class instances like Role, Bucket, etc.), +this is always the same as the environment of the stack they belong to; +however, for imported resources +(those obtained from static methods like fromRoleArn, fromBucketName, etc.), +that might be different than the stack they were imported into. + +--- + +##### `stack`Required + +```typescript +public readonly stack: Stack; +``` + +- *Type:* aws-cdk-lib.Stack + +The stack in which this resource is defined. + +--- + +##### `connections`Required + +```typescript +public readonly connections: Connections; +``` + +- *Type:* aws-cdk-lib.aws_ec2.Connections + +The connection object associated with the EC2 Instance Connect Endpoint. + +--- + +##### `instanceConnectEndpointId`Required + +```typescript +public readonly instanceConnectEndpointId: string; +``` + +- *Type:* string + +The ID of the EC2 Instance Connect Endpoint. + +--- + + ## Structs ### CostReportProps @@ -222,6 +503,128 @@ The granularity of the line items in the report. --- +### InstanceConnectEndpointAttributes + +Attributes for importing an EC2 Instance Connect Endpoint. + +#### Initializer + +```typescript +import { aws_ec2 } from '@open-constructs/aws-cdk' + +const instanceConnectEndpointAttributes: aws_ec2.InstanceConnectEndpointAttributes = { ... } +``` + +#### Properties + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| instanceConnectEndpointId | string | The ID of the EC2 Instance Connect Endpoint. | +| securityGroups | aws-cdk-lib.aws_ec2.ISecurityGroup[] | The security groups associated with the EC2 Instance Connect Endpoint. | + +--- + +##### `instanceConnectEndpointId`Required + +```typescript +public readonly instanceConnectEndpointId: string; +``` + +- *Type:* string + +The ID of the EC2 Instance Connect Endpoint. + +--- + +##### `securityGroups`Required + +```typescript +public readonly securityGroups: ISecurityGroup[]; +``` + +- *Type:* aws-cdk-lib.aws_ec2.ISecurityGroup[] + +The security groups associated with the EC2 Instance Connect Endpoint. + +--- + +### InstanceConnectEndpointProps + +Properties for defining an EC2 Instance Connect Endpoint. + +#### Initializer + +```typescript +import { aws_ec2 } from '@open-constructs/aws-cdk' + +const instanceConnectEndpointProps: aws_ec2.InstanceConnectEndpointProps = { ... } +``` + +#### Properties + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| vpc | aws-cdk-lib.aws_ec2.IVpc | The VPC in which the EC2 Instance Connect Endpoint is created. | +| clientToken | string | Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. | +| preserveClientIp | boolean | Indicates whether your client's IP address is preserved as the source. | +| securityGroups | aws-cdk-lib.aws_ec2.ISecurityGroup[] | The security groups to associate with the EC2 Instance Connect Endpoint. | + +--- + +##### `vpc`Required + +```typescript +public readonly vpc: IVpc; +``` + +- *Type:* aws-cdk-lib.aws_ec2.IVpc + +The VPC in which the EC2 Instance Connect Endpoint is created. + +--- + +##### `clientToken`Optional + +```typescript +public readonly clientToken: string; +``` + +- *Type:* string + +Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. + +> [https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-instanceconnectendpoint.html#cfn-ec2-instanceconnectendpoint-clienttoken](https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-instanceconnectendpoint.html#cfn-ec2-instanceconnectendpoint-clienttoken) + +--- + +##### `preserveClientIp`Optional + +```typescript +public readonly preserveClientIp: boolean; +``` + +- *Type:* boolean +- *Default:* true + +Indicates whether your client's IP address is preserved as the source. + +> [https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-instanceconnectendpoint.html#cfn-ec2-instanceconnectendpoint-preserveclientip](https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-instanceconnectendpoint.html#cfn-ec2-instanceconnectendpoint-preserveclientip) + +--- + +##### `securityGroups`Optional + +```typescript +public readonly securityGroups: ISecurityGroup[]; +``` + +- *Type:* aws-cdk-lib.aws_ec2.ISecurityGroup[] +- *Default:* a new security group is created + +The security groups to associate with the EC2 Instance Connect Endpoint. + +--- + ## Classes ### CurFormat @@ -467,4 +870,93 @@ Weekly granularity. --- +## Protocols + +### IInstanceConnectEndpoint + +- *Extends:* aws-cdk-lib.aws_ec2.IConnectable, aws-cdk-lib.IResource + +- *Implemented By:* @open-constructs/aws-cdk.aws_ec2.InstanceConnectEndpoint, @open-constructs/aws-cdk.aws_ec2.IInstanceConnectEndpoint + +An EC2 Instance Connect Endpoint. + + +#### Properties + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| connections | aws-cdk-lib.aws_ec2.Connections | The network connections associated with this resource. | +| node | constructs.Node | The tree node. | +| env | aws-cdk-lib.ResourceEnvironment | The environment this resource belongs to. | +| stack | aws-cdk-lib.Stack | The stack in which this resource is defined. | +| instanceConnectEndpointId | string | The ID of the EC2 Instance Connect Endpoint. | + +--- + +##### `connections`Required + +```typescript +public readonly connections: Connections; +``` + +- *Type:* aws-cdk-lib.aws_ec2.Connections + +The network connections associated with this resource. + +--- + +##### `node`Required + +```typescript +public readonly node: Node; +``` + +- *Type:* constructs.Node + +The tree node. + +--- + +##### `env`Required + +```typescript +public readonly env: ResourceEnvironment; +``` + +- *Type:* aws-cdk-lib.ResourceEnvironment + +The environment this resource belongs to. + +For resources that are created and managed by the CDK +(generally, those created by creating new class instances like Role, Bucket, etc.), +this is always the same as the environment of the stack they belong to; +however, for imported resources +(those obtained from static methods like fromRoleArn, fromBucketName, etc.), +that might be different than the stack they were imported into. + +--- + +##### `stack`Required + +```typescript +public readonly stack: Stack; +``` + +- *Type:* aws-cdk-lib.Stack + +The stack in which this resource is defined. + +--- + +##### `instanceConnectEndpointId`Required + +```typescript +public readonly instanceConnectEndpointId: string; +``` + +- *Type:* string + +The ID of the EC2 Instance Connect Endpoint. + +--- diff --git a/src/aws-ec2/README.md b/src/aws-ec2/README.md new file mode 100644 index 0000000..ce0e0b7 --- /dev/null +++ b/src/aws-ec2/README.md @@ -0,0 +1,78 @@ +Constructs for the AWS EC2 service + +# EC2 Instance Connect Endpoint CDK Construct + +## Overview + +The `InstanceConnectEndpoint` construct facilitates the creation and management of [EC2 Instance Connect endpoints](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/connect-with-ec2-instance-connect-endpoint.html) +within AWS CDK applications. + +## Usage + +Import the necessary classes from AWS CDK and this construct and create a VPC for the endpoint: + +```ts +import { App, Stack } from 'aws-cdk-lib'; +import * as ec2 from 'aws-cdk-lib/aws-ec2'; +import { InstanceConnectEndpoint } from '@open-constructs/aws-cdk/aws-ec2'; + +const app = new App(); +const stack = new Stack(app, 'InstanceConnectEndpointStack'); +const vpc = new ec2.Vpc(stack, 'MyVpc'); +``` + +### Basic Example + +Here's how you can create an EC2 Instance Connect endpoint and allow connections to an EC2 instance: + +```ts +const instance = new ec2.Instance(this, 'Instance', { + vpc, + instanceType: ec2.InstanceType.of( + ec2.InstanceClass.C5, + ec2.InstanceSize.LARGE, + ), + machineImage: new ec2.AmazonLinuxImage({ + generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2023, + }), +}); + +const endpoint = new InstanceConnectEndpoint(stack, 'MyEndpoint', { + vpc, +}); + +// Allow SSH connections to the instance +// You can also use the port 3389 for RDP connections +endpoint.connections.allowTo(instance, ec2.Port.tcp(22)); +``` + +### Advanced Example + +Creating an endpoint with a custom settings: + +```ts +declare const endpointSecurityGroup: ec2.ISecurityGroup; + +const endpoint = new InstanceConnectEndpoint(stack, 'MyCustomEndpoint', { + vpc, + securityGroups: [endpointSecurityGroup], // Specify user-defined security groups + preserveClientIp: true, // Whether your client's IP address is preserved as the source + clientToken: 'my-client-token', // Specify client token to ensure the idempotency of the request. +}); +``` + +Import an existing endpoint: + +```ts +declare const existingEndpoint: ec2.IInstanceConnectEndpoint; +declare const securityGroups: ec2.ISecurityGroup[]; + +const existingEndpoint = InstanceConnectEndpoint.fromInstanceConnectEndpointAttributes( + stack, + 'MyExistingEndpoint', + { + instanceConnectEndpointId: existingEndpoint.instanceConnectEndpointId, + securityGroups, + }, +); +``` diff --git a/src/aws-ec2/index.ts b/src/aws-ec2/index.ts new file mode 100644 index 0000000..84f2ecf --- /dev/null +++ b/src/aws-ec2/index.ts @@ -0,0 +1 @@ +export * from './instance-connect-endpoint'; \ No newline at end of file diff --git a/src/aws-ec2/instance-connect-endpoint.ts b/src/aws-ec2/instance-connect-endpoint.ts new file mode 100644 index 0000000..a122f79 --- /dev/null +++ b/src/aws-ec2/instance-connect-endpoint.ts @@ -0,0 +1,144 @@ +import { IResource, Resource, aws_ec2 } from 'aws-cdk-lib'; +import { Construct } from 'constructs'; + +/** + * An EC2 Instance Connect Endpoint. + */ +export interface IInstanceConnectEndpoint extends aws_ec2.IConnectable, IResource { + /** + * The ID of the EC2 Instance Connect Endpoint. + * + * @attribute + */ + readonly instanceConnectEndpointId: string; +} + +/** + * Properties for defining an EC2 Instance Connect Endpoint. + */ +export interface InstanceConnectEndpointProps { + /** + * Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. + * + * @see https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-instanceconnectendpoint.html#cfn-ec2-instanceconnectendpoint-clienttoken + */ + readonly clientToken?: string; + + /** + * Indicates whether your client's IP address is preserved as the source. + * + * @see https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-instanceconnectendpoint.html#cfn-ec2-instanceconnectendpoint-preserveclientip + * @default true + */ + readonly preserveClientIp?: boolean; + + /** + * The security groups to associate with the EC2 Instance Connect Endpoint. + * + * @default - a new security group is created + */ + readonly securityGroups?: aws_ec2.ISecurityGroup[]; + + /** + * The VPC in which the EC2 Instance Connect Endpoint is created. + */ + readonly vpc: aws_ec2.IVpc; +} + +/** + * Attributes for importing an EC2 Instance Connect Endpoint. + */ +export interface InstanceConnectEndpointAttributes { + /** + * The ID of the EC2 Instance Connect Endpoint. + */ + readonly instanceConnectEndpointId: string; + + /** + * The security groups associated with the EC2 Instance Connect Endpoint. + */ + readonly securityGroups: aws_ec2.ISecurityGroup[]; +} + +/** + * Represents an EC2 Instance Connect Endpoint construct in AWS CDK. + * + * @example + * declare const securityGroups: aws_ec2.ISecurityGroup[]; + * declare const vpc: aws_ec2.IVpc; + * + * const instanceConnectEndpoint = new InstanceConnectEndpoint( + * stack, + * 'InstanceConnectEndpoint', + * { + * clientToken: 'my-client-token', + * preserveClientIp: true, + * securityGroups, + * vpc, + * }, + * ); + */ +export class InstanceConnectEndpoint extends Resource implements IInstanceConnectEndpoint { + + /** + * Import an existing endpoint to the stack from its attributes. + */ + public static fromInstanceConnectEndpointAttributes( + scope: Construct, + id: string, + attrs: InstanceConnectEndpointAttributes, + ): IInstanceConnectEndpoint { + class Import extends Resource implements IInstanceConnectEndpoint { + public readonly instanceConnectEndpointId = attrs.instanceConnectEndpointId; + public readonly connections = new aws_ec2.Connections({ + securityGroups: attrs.securityGroups, + }); + } + + return new Import(scope, id); + } + + /** + * The ID of the EC2 Instance Connect Endpoint. + */ + public readonly instanceConnectEndpointId: string; + + /** + * The connection object associated with the EC2 Instance Connect Endpoint. + */ + public readonly connections: aws_ec2.Connections; + + private readonly props: InstanceConnectEndpointProps; + private readonly securityGroups: aws_ec2.ISecurityGroup[]; + + constructor(scope: Construct, id: string, props: InstanceConnectEndpointProps) { + super(scope, id); + this.props = props; + + this.securityGroups = props.securityGroups ?? [this.createSecurityGroup()]; + + this.connections = new aws_ec2.Connections({ + securityGroups: this.securityGroups, + }); + + const instanceConnectEndpoint = this.createInstanceConnectEndpoint(); + + this.instanceConnectEndpointId = instanceConnectEndpoint.attrId; + } + + protected createInstanceConnectEndpoint(): aws_ec2.CfnInstanceConnectEndpoint { + return new aws_ec2.CfnInstanceConnectEndpoint(this, 'Resource', { + clientToken: this.props.clientToken, + preserveClientIp: this.props.preserveClientIp, + securityGroupIds: this.securityGroups.map(sg => sg.securityGroupId), + subnetId: this.props.vpc.selectSubnets().subnetIds[0], + }); + } + + protected createSecurityGroup(): aws_ec2.SecurityGroup { + return new aws_ec2.SecurityGroup(this, 'SecurityGroup', { + vpc: this.props.vpc, + }); + } +} + diff --git a/src/index.ts b/src/index.ts index 60a7b53..8b2b719 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,2 +1,3 @@ // Export constructs here -export * as aws_cur from './aws-cur'; \ No newline at end of file +export * as aws_cur from './aws-cur'; +export * as aws_ec2 from './aws-ec2'; \ No newline at end of file diff --git a/test/aws-ec2/instance-connect-endpoint.test.ts b/test/aws-ec2/instance-connect-endpoint.test.ts new file mode 100644 index 0000000..5439ef7 --- /dev/null +++ b/test/aws-ec2/instance-connect-endpoint.test.ts @@ -0,0 +1,74 @@ +import { App, Stack, aws_ec2 } from 'aws-cdk-lib'; +import { Template } from 'aws-cdk-lib/assertions'; +import { InstanceConnectEndpoint } from '../../src/aws-ec2'; + +describe('InstanceConnectEndpoint', () => { + let app: App; + let stack: Stack; + + beforeEach(() => { + app = new App(); + stack = new Stack(app, 'TestStack'); + }); + + test('default configuration', () => { + new InstanceConnectEndpoint(stack, 'MyInstanceConnectEndpoint', { + vpc: new aws_ec2.Vpc(stack, 'VPC', { + maxAzs: 2, + }), + }); + + Template.fromStack(stack).hasResourceProperties('AWS::EC2::InstanceConnectEndpoint', { + SecurityGroupIds: [ + { 'Fn::GetAtt': ['MyInstanceConnectEndpointSecurityGroup99B9E814', 'GroupId'] }, + ], + SubnetId: { Ref: 'VPCPrivateSubnet1Subnet8BCA10E0' }, + }); + }); + + test('custom configuration', () => { + const vpc = new aws_ec2.Vpc(stack, 'VPC', { + maxAzs: 2, + }); + new InstanceConnectEndpoint(stack, 'MyCustomInstanceConnectEndpoint', { + vpc, + clientToken: 'my-client-token', + preserveClientIp: false, + securityGroups: [ + new aws_ec2.SecurityGroup(stack, 'SecurityGroup', { + vpc, + allowAllOutbound: false, + }), + ], + }); + + Template.fromStack(stack).hasResourceProperties('AWS::EC2::InstanceConnectEndpoint', { + ClientToken: 'my-client-token', + PreserveClientIp: false, + SecurityGroupIds: [ + { 'Fn::GetAtt': ['SecurityGroupDD263621', 'GroupId'] }, + ], + SubnetId: { Ref: 'VPCPrivateSubnet1Subnet8BCA10E0' }, + }); + }); + + test('import from attributes', () => { + const vpc = new aws_ec2.Vpc(stack, 'VPC'); + const securityGroup = new aws_ec2.SecurityGroup(stack, 'SecurityGroup', { + vpc, + allowAllOutbound: false, + }); + + const existingEndpoint = InstanceConnectEndpoint.fromInstanceConnectEndpointAttributes( + stack, + 'ImportedInstanceConnectEndpoint', + { + instanceConnectEndpointId: 'my-endpoint-id', + securityGroups: [securityGroup], + }, + ); + + expect(existingEndpoint.instanceConnectEndpointId).toEqual('my-endpoint-id'); + expect(existingEndpoint.connections.securityGroups).toEqual([securityGroup]); + }); +}); diff --git a/test/aws-ec2/integ.instance-connect-endpoint.ts b/test/aws-ec2/integ.instance-connect-endpoint.ts new file mode 100644 index 0000000..1349503 --- /dev/null +++ b/test/aws-ec2/integ.instance-connect-endpoint.ts @@ -0,0 +1,49 @@ +import { IntegTest } from '@aws-cdk/integ-tests-alpha'; +import * as cdk from 'aws-cdk-lib'; +import { Construct } from 'constructs'; +import * as ocf from '../../src'; + +class InstanceConnectEndpointStack extends cdk.Stack { + constructor(scope: Construct) { + super(scope, 'InstanceConnectEndpointStack'); + + const vpc = new cdk.aws_ec2.Vpc(this, 'VPC', { + maxAzs: 2, + }); + + const instance = new cdk.aws_ec2.Instance(this, 'Instance', { + vpc, + instanceType: cdk.aws_ec2.InstanceType.of( + cdk.aws_ec2.InstanceClass.C5, + cdk.aws_ec2.InstanceSize.LARGE, + ), + machineImage: new cdk.aws_ec2.AmazonLinuxImage({ + generation: cdk.aws_ec2.AmazonLinuxGeneration.AMAZON_LINUX_2023, + }), + }); + + const securityGroup = new cdk.aws_ec2.SecurityGroup(this, 'SecurityGroup', { + vpc, + allowAllOutbound: false, + }); + + const instanceConnectEndpoint = new ocf.aws_ec2.InstanceConnectEndpoint( + this, + 'InstanceConnectEndpoint', + { + clientToken: 'my-client-token', + securityGroups: [securityGroup], + preserveClientIp: true, + vpc, + }, + ); + + instanceConnectEndpoint.connections.allowTo(instance, cdk.aws_ec2.Port.tcp(22)); + } +} + +const app = new cdk.App(); +const testCase = new InstanceConnectEndpointStack(app); +new IntegTest(app, 'InstanceConnectEndpoint', { + testCases: [testCase], +}); diff --git a/test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/InstanceConnectEndpointDefaultTestDeployAssert284B1FD7.assets.json b/test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/InstanceConnectEndpointDefaultTestDeployAssert284B1FD7.assets.json new file mode 100644 index 0000000..6d7294d --- /dev/null +++ b/test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/InstanceConnectEndpointDefaultTestDeployAssert284B1FD7.assets.json @@ -0,0 +1,19 @@ +{ + "version": "36.0.0", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "InstanceConnectEndpointDefaultTestDeployAssert284B1FD7.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/InstanceConnectEndpointDefaultTestDeployAssert284B1FD7.template.json b/test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/InstanceConnectEndpointDefaultTestDeployAssert284B1FD7.template.json new file mode 100644 index 0000000..ad9d0fb --- /dev/null +++ b/test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/InstanceConnectEndpointDefaultTestDeployAssert284B1FD7.template.json @@ -0,0 +1,36 @@ +{ + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/InstanceConnectEndpointStack.assets.json b/test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/InstanceConnectEndpointStack.assets.json new file mode 100644 index 0000000..31e2a29 --- /dev/null +++ b/test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/InstanceConnectEndpointStack.assets.json @@ -0,0 +1,32 @@ +{ + "version": "36.0.0", + "files": { + "dd5711540f04e06aa955d7f4862fc04e8cdea464cb590dae91ed2976bb78098e": { + "source": { + "path": "asset.dd5711540f04e06aa955d7f4862fc04e8cdea464cb590dae91ed2976bb78098e", + "packaging": "zip" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "dd5711540f04e06aa955d7f4862fc04e8cdea464cb590dae91ed2976bb78098e.zip", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + }, + "0c30d0501af434d3551d71e0423d0b989083d4d2f748dfae2cd738cc08f4c904": { + "source": { + "path": "InstanceConnectEndpointStack.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "0c30d0501af434d3551d71e0423d0b989083d4d2f748dfae2cd738cc08f4c904.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/InstanceConnectEndpointStack.template.json b/test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/InstanceConnectEndpointStack.template.json new file mode 100644 index 0000000..e757b7d --- /dev/null +++ b/test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/InstanceConnectEndpointStack.template.json @@ -0,0 +1,716 @@ +{ + "Resources": { + "VPCB9E5F0B4": { + "Type": "AWS::EC2::VPC", + "Properties": { + "CidrBlock": "10.0.0.0/16", + "EnableDnsHostnames": true, + "EnableDnsSupport": true, + "InstanceTenancy": "default", + "Tags": [ + { + "Key": "Name", + "Value": "InstanceConnectEndpointStack/VPC" + } + ] + } + }, + "VPCPublicSubnet1SubnetB4246D30": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "AvailabilityZone": { + "Fn::Select": [ + 0, + { + "Fn::GetAZs": "" + } + ] + }, + "CidrBlock": "10.0.0.0/18", + "MapPublicIpOnLaunch": true, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Public" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Public" + }, + { + "Key": "Name", + "Value": "InstanceConnectEndpointStack/VPC/PublicSubnet1" + } + ], + "VpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "VPCPublicSubnet1RouteTableFEE4B781": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "InstanceConnectEndpointStack/VPC/PublicSubnet1" + } + ], + "VpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "VPCPublicSubnet1RouteTableAssociation0B0896DC": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VPCPublicSubnet1RouteTableFEE4B781" + }, + "SubnetId": { + "Ref": "VPCPublicSubnet1SubnetB4246D30" + } + } + }, + "VPCPublicSubnet1DefaultRoute91CEF279": { + "Type": "AWS::EC2::Route", + "Properties": { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": { + "Ref": "VPCIGWB7E252D3" + }, + "RouteTableId": { + "Ref": "VPCPublicSubnet1RouteTableFEE4B781" + } + }, + "DependsOn": [ + "VPCVPCGW99B986DC" + ] + }, + "VPCPublicSubnet1EIP6AD938E8": { + "Type": "AWS::EC2::EIP", + "Properties": { + "Domain": "vpc", + "Tags": [ + { + "Key": "Name", + "Value": "InstanceConnectEndpointStack/VPC/PublicSubnet1" + } + ] + } + }, + "VPCPublicSubnet1NATGatewayE0556630": { + "Type": "AWS::EC2::NatGateway", + "Properties": { + "AllocationId": { + "Fn::GetAtt": [ + "VPCPublicSubnet1EIP6AD938E8", + "AllocationId" + ] + }, + "SubnetId": { + "Ref": "VPCPublicSubnet1SubnetB4246D30" + }, + "Tags": [ + { + "Key": "Name", + "Value": "InstanceConnectEndpointStack/VPC/PublicSubnet1" + } + ] + }, + "DependsOn": [ + "VPCPublicSubnet1DefaultRoute91CEF279", + "VPCPublicSubnet1RouteTableAssociation0B0896DC" + ] + }, + "VPCPublicSubnet2Subnet74179F39": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "AvailabilityZone": { + "Fn::Select": [ + 1, + { + "Fn::GetAZs": "" + } + ] + }, + "CidrBlock": "10.0.64.0/18", + "MapPublicIpOnLaunch": true, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Public" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Public" + }, + { + "Key": "Name", + "Value": "InstanceConnectEndpointStack/VPC/PublicSubnet2" + } + ], + "VpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "VPCPublicSubnet2RouteTable6F1A15F1": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "InstanceConnectEndpointStack/VPC/PublicSubnet2" + } + ], + "VpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "VPCPublicSubnet2RouteTableAssociation5A808732": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VPCPublicSubnet2RouteTable6F1A15F1" + }, + "SubnetId": { + "Ref": "VPCPublicSubnet2Subnet74179F39" + } + } + }, + "VPCPublicSubnet2DefaultRouteB7481BBA": { + "Type": "AWS::EC2::Route", + "Properties": { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": { + "Ref": "VPCIGWB7E252D3" + }, + "RouteTableId": { + "Ref": "VPCPublicSubnet2RouteTable6F1A15F1" + } + }, + "DependsOn": [ + "VPCVPCGW99B986DC" + ] + }, + "VPCPublicSubnet2EIP4947BC00": { + "Type": "AWS::EC2::EIP", + "Properties": { + "Domain": "vpc", + "Tags": [ + { + "Key": "Name", + "Value": "InstanceConnectEndpointStack/VPC/PublicSubnet2" + } + ] + } + }, + "VPCPublicSubnet2NATGateway3C070193": { + "Type": "AWS::EC2::NatGateway", + "Properties": { + "AllocationId": { + "Fn::GetAtt": [ + "VPCPublicSubnet2EIP4947BC00", + "AllocationId" + ] + }, + "SubnetId": { + "Ref": "VPCPublicSubnet2Subnet74179F39" + }, + "Tags": [ + { + "Key": "Name", + "Value": "InstanceConnectEndpointStack/VPC/PublicSubnet2" + } + ] + }, + "DependsOn": [ + "VPCPublicSubnet2DefaultRouteB7481BBA", + "VPCPublicSubnet2RouteTableAssociation5A808732" + ] + }, + "VPCPrivateSubnet1Subnet8BCA10E0": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "AvailabilityZone": { + "Fn::Select": [ + 0, + { + "Fn::GetAZs": "" + } + ] + }, + "CidrBlock": "10.0.128.0/18", + "MapPublicIpOnLaunch": false, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Private" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Private" + }, + { + "Key": "Name", + "Value": "InstanceConnectEndpointStack/VPC/PrivateSubnet1" + } + ], + "VpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "VPCPrivateSubnet1RouteTableBE8A6027": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "InstanceConnectEndpointStack/VPC/PrivateSubnet1" + } + ], + "VpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "VPCPrivateSubnet1RouteTableAssociation347902D1": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VPCPrivateSubnet1RouteTableBE8A6027" + }, + "SubnetId": { + "Ref": "VPCPrivateSubnet1Subnet8BCA10E0" + } + } + }, + "VPCPrivateSubnet1DefaultRouteAE1D6490": { + "Type": "AWS::EC2::Route", + "Properties": { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": { + "Ref": "VPCPublicSubnet1NATGatewayE0556630" + }, + "RouteTableId": { + "Ref": "VPCPrivateSubnet1RouteTableBE8A6027" + } + } + }, + "VPCPrivateSubnet2SubnetCFCDAA7A": { + "Type": "AWS::EC2::Subnet", + "Properties": { + "AvailabilityZone": { + "Fn::Select": [ + 1, + { + "Fn::GetAZs": "" + } + ] + }, + "CidrBlock": "10.0.192.0/18", + "MapPublicIpOnLaunch": false, + "Tags": [ + { + "Key": "aws-cdk:subnet-name", + "Value": "Private" + }, + { + "Key": "aws-cdk:subnet-type", + "Value": "Private" + }, + { + "Key": "Name", + "Value": "InstanceConnectEndpointStack/VPC/PrivateSubnet2" + } + ], + "VpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "VPCPrivateSubnet2RouteTable0A19E10E": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "InstanceConnectEndpointStack/VPC/PrivateSubnet2" + } + ], + "VpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "VPCPrivateSubnet2RouteTableAssociation0C73D413": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "VPCPrivateSubnet2RouteTable0A19E10E" + }, + "SubnetId": { + "Ref": "VPCPrivateSubnet2SubnetCFCDAA7A" + } + } + }, + "VPCPrivateSubnet2DefaultRouteF4F5CFD2": { + "Type": "AWS::EC2::Route", + "Properties": { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": { + "Ref": "VPCPublicSubnet2NATGateway3C070193" + }, + "RouteTableId": { + "Ref": "VPCPrivateSubnet2RouteTable0A19E10E" + } + } + }, + "VPCIGWB7E252D3": { + "Type": "AWS::EC2::InternetGateway", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "InstanceConnectEndpointStack/VPC" + } + ] + } + }, + "VPCVPCGW99B986DC": { + "Type": "AWS::EC2::VPCGatewayAttachment", + "Properties": { + "InternetGatewayId": { + "Ref": "VPCIGWB7E252D3" + }, + "VpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "VPCRestrictDefaultSecurityGroupCustomResource59474679": { + "Type": "Custom::VpcRestrictDefaultSG", + "Properties": { + "ServiceToken": { + "Fn::GetAtt": [ + "CustomVpcRestrictDefaultSGCustomResourceProviderHandlerDC833E5E", + "Arn" + ] + }, + "DefaultSecurityGroupId": { + "Fn::GetAtt": [ + "VPCB9E5F0B4", + "DefaultSecurityGroup" + ] + }, + "Account": { + "Ref": "AWS::AccountId" + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "CustomVpcRestrictDefaultSGCustomResourceProviderRole26592FE0": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ] + }, + "ManagedPolicyArns": [ + { + "Fn::Sub": "arn:${AWS::Partition}:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + } + ], + "Policies": [ + { + "PolicyName": "Inline", + "PolicyDocument": { + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Action": [ + "ec2:AuthorizeSecurityGroupIngress", + "ec2:AuthorizeSecurityGroupEgress", + "ec2:RevokeSecurityGroupIngress", + "ec2:RevokeSecurityGroupEgress" + ], + "Resource": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":ec2:", + { + "Ref": "AWS::Region" + }, + ":", + { + "Ref": "AWS::AccountId" + }, + ":security-group/", + { + "Fn::GetAtt": [ + "VPCB9E5F0B4", + "DefaultSecurityGroup" + ] + } + ] + ] + } + ] + } + ] + } + } + ] + } + }, + "CustomVpcRestrictDefaultSGCustomResourceProviderHandlerDC833E5E": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": { + "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" + }, + "S3Key": "dd5711540f04e06aa955d7f4862fc04e8cdea464cb590dae91ed2976bb78098e.zip" + }, + "Timeout": 900, + "MemorySize": 128, + "Handler": "__entrypoint__.handler", + "Role": { + "Fn::GetAtt": [ + "CustomVpcRestrictDefaultSGCustomResourceProviderRole26592FE0", + "Arn" + ] + }, + "Runtime": "nodejs18.x", + "Description": "Lambda function for removing all inbound/outbound rules from the VPC default security group" + }, + "DependsOn": [ + "CustomVpcRestrictDefaultSGCustomResourceProviderRole26592FE0" + ] + }, + "InstanceInstanceSecurityGroupF0E2D5BE": { + "Type": "AWS::EC2::SecurityGroup", + "Properties": { + "GroupDescription": "InstanceConnectEndpointStack/Instance/InstanceSecurityGroup", + "SecurityGroupEgress": [ + { + "CidrIp": "0.0.0.0/0", + "Description": "Allow all outbound traffic by default", + "IpProtocol": "-1" + } + ], + "Tags": [ + { + "Key": "Name", + "Value": "InstanceConnectEndpointStack/Instance" + } + ], + "VpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "InstanceInstanceSecurityGroupfromInstanceConnectEndpointStackSecurityGroupAB1BD525228343766C": { + "Type": "AWS::EC2::SecurityGroupIngress", + "Properties": { + "Description": "from InstanceConnectEndpointStackSecurityGroupAB1BD525:22", + "FromPort": 22, + "GroupId": { + "Fn::GetAtt": [ + "InstanceInstanceSecurityGroupF0E2D5BE", + "GroupId" + ] + }, + "IpProtocol": "tcp", + "SourceSecurityGroupId": { + "Fn::GetAtt": [ + "SecurityGroupDD263621", + "GroupId" + ] + }, + "ToPort": 22 + } + }, + "InstanceInstanceRoleE9785DE5": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "ec2.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "Tags": [ + { + "Key": "Name", + "Value": "InstanceConnectEndpointStack/Instance" + } + ] + } + }, + "InstanceInstanceProfileAB5AEF02": { + "Type": "AWS::IAM::InstanceProfile", + "Properties": { + "Roles": [ + { + "Ref": "InstanceInstanceRoleE9785DE5" + } + ] + } + }, + "InstanceC1063A87": { + "Type": "AWS::EC2::Instance", + "Properties": { + "AvailabilityZone": { + "Fn::Select": [ + 0, + { + "Fn::GetAZs": "" + } + ] + }, + "IamInstanceProfile": { + "Ref": "InstanceInstanceProfileAB5AEF02" + }, + "ImageId": { + "Ref": "SsmParameterValueawsserviceamiamazonlinuxlatestal2023amikernel61x8664C96584B6F00A464EAD1953AFF4B05118Parameter" + }, + "InstanceType": "c5.large", + "SecurityGroupIds": [ + { + "Fn::GetAtt": [ + "InstanceInstanceSecurityGroupF0E2D5BE", + "GroupId" + ] + } + ], + "SubnetId": { + "Ref": "VPCPrivateSubnet1Subnet8BCA10E0" + }, + "Tags": [ + { + "Key": "Name", + "Value": "InstanceConnectEndpointStack/Instance" + } + ], + "UserData": { + "Fn::Base64": "#!/bin/bash" + } + }, + "DependsOn": [ + "InstanceInstanceRoleE9785DE5" + ] + }, + "SecurityGroupDD263621": { + "Type": "AWS::EC2::SecurityGroup", + "Properties": { + "GroupDescription": "InstanceConnectEndpointStack/SecurityGroup", + "VpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "SecurityGrouptoInstanceConnectEndpointStackInstanceInstanceSecurityGroupED8DD45C22FB84383F": { + "Type": "AWS::EC2::SecurityGroupEgress", + "Properties": { + "Description": "to InstanceConnectEndpointStackInstanceInstanceSecurityGroupED8DD45C:22", + "DestinationSecurityGroupId": { + "Fn::GetAtt": [ + "InstanceInstanceSecurityGroupF0E2D5BE", + "GroupId" + ] + }, + "FromPort": 22, + "GroupId": { + "Fn::GetAtt": [ + "SecurityGroupDD263621", + "GroupId" + ] + }, + "IpProtocol": "tcp", + "ToPort": 22 + } + }, + "InstanceConnectEndpointAC315DCA": { + "Type": "AWS::EC2::InstanceConnectEndpoint", + "Properties": { + "ClientToken": "my-client-token", + "PreserveClientIp": true, + "SecurityGroupIds": [ + { + "Fn::GetAtt": [ + "SecurityGroupDD263621", + "GroupId" + ] + } + ], + "SubnetId": { + "Ref": "VPCPrivateSubnet1Subnet8BCA10E0" + } + } + } + }, + "Parameters": { + "SsmParameterValueawsserviceamiamazonlinuxlatestal2023amikernel61x8664C96584B6F00A464EAD1953AFF4B05118Parameter": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/aws/service/ami-amazon-linux-latest/al2023-ami-kernel-6.1-x86_64" + }, + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/asset.dd5711540f04e06aa955d7f4862fc04e8cdea464cb590dae91ed2976bb78098e/__entrypoint__.js b/test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/asset.dd5711540f04e06aa955d7f4862fc04e8cdea464cb590dae91ed2976bb78098e/__entrypoint__.js new file mode 100644 index 0000000..5a1714e --- /dev/null +++ b/test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/asset.dd5711540f04e06aa955d7f4862fc04e8cdea464cb590dae91ed2976bb78098e/__entrypoint__.js @@ -0,0 +1 @@ +"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.withRetries=exports.handler=exports.external=void 0;const https=require("https"),url=require("url");exports.external={sendHttpRequest:defaultSendHttpRequest,log:defaultLog,includeStackTraces:!0,userHandlerIndex:"./index"};const CREATE_FAILED_PHYSICAL_ID_MARKER="AWSCDK::CustomResourceProviderFramework::CREATE_FAILED",MISSING_PHYSICAL_ID_MARKER="AWSCDK::CustomResourceProviderFramework::MISSING_PHYSICAL_ID";async function handler(event,context){const sanitizedEvent={...event,ResponseURL:"..."};if(exports.external.log(JSON.stringify(sanitizedEvent,void 0,2)),event.RequestType==="Delete"&&event.PhysicalResourceId===CREATE_FAILED_PHYSICAL_ID_MARKER){exports.external.log("ignoring DELETE event caused by a failed CREATE event"),await submitResponse("SUCCESS",event);return}try{const userHandler=require(exports.external.userHandlerIndex).handler,result=await userHandler(sanitizedEvent,context),responseEvent=renderResponse(event,result);await submitResponse("SUCCESS",responseEvent)}catch(e){const resp={...event,Reason:exports.external.includeStackTraces?e.stack:e.message};resp.PhysicalResourceId||(event.RequestType==="Create"?(exports.external.log("CREATE failed, responding with a marker physical resource id so that the subsequent DELETE will be ignored"),resp.PhysicalResourceId=CREATE_FAILED_PHYSICAL_ID_MARKER):exports.external.log(`ERROR: Malformed event. "PhysicalResourceId" is required: ${JSON.stringify(event)}`)),await submitResponse("FAILED",resp)}}exports.handler=handler;function renderResponse(cfnRequest,handlerResponse={}){const physicalResourceId=handlerResponse.PhysicalResourceId??cfnRequest.PhysicalResourceId??cfnRequest.RequestId;if(cfnRequest.RequestType==="Delete"&&physicalResourceId!==cfnRequest.PhysicalResourceId)throw new Error(`DELETE: cannot change the physical resource ID from "${cfnRequest.PhysicalResourceId}" to "${handlerResponse.PhysicalResourceId}" during deletion`);return{...cfnRequest,...handlerResponse,PhysicalResourceId:physicalResourceId}}async function submitResponse(status,event){const json={Status:status,Reason:event.Reason??status,StackId:event.StackId,RequestId:event.RequestId,PhysicalResourceId:event.PhysicalResourceId||MISSING_PHYSICAL_ID_MARKER,LogicalResourceId:event.LogicalResourceId,NoEcho:event.NoEcho,Data:event.Data};exports.external.log("submit response to cloudformation",json);const responseBody=JSON.stringify(json),parsedUrl=url.parse(event.ResponseURL),req={hostname:parsedUrl.hostname,path:parsedUrl.path,method:"PUT",headers:{"content-type":"","content-length":Buffer.byteLength(responseBody,"utf8")}};await withRetries({attempts:5,sleep:1e3},exports.external.sendHttpRequest)(req,responseBody)}async function defaultSendHttpRequest(options,responseBody){return new Promise((resolve,reject)=>{try{const request=https.request(options,_=>resolve());request.on("error",reject),request.write(responseBody),request.end()}catch(e){reject(e)}})}function defaultLog(fmt,...params){console.log(fmt,...params)}function withRetries(options,fn){return async(...xs)=>{let attempts=options.attempts,ms=options.sleep;for(;;)try{return await fn(...xs)}catch(e){if(attempts--<=0)throw e;await sleep(Math.floor(Math.random()*ms)),ms*=2}}}exports.withRetries=withRetries;async function sleep(ms){return new Promise(ok=>setTimeout(ok,ms))} diff --git a/test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/asset.dd5711540f04e06aa955d7f4862fc04e8cdea464cb590dae91ed2976bb78098e/index.js b/test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/asset.dd5711540f04e06aa955d7f4862fc04e8cdea464cb590dae91ed2976bb78098e/index.js new file mode 100644 index 0000000..9f1466d --- /dev/null +++ b/test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/asset.dd5711540f04e06aa955d7f4862fc04e8cdea464cb590dae91ed2976bb78098e/index.js @@ -0,0 +1 @@ +"use strict";var I=Object.create,t=Object.defineProperty,y=Object.getOwnPropertyDescriptor,P=Object.getOwnPropertyNames,g=Object.getPrototypeOf,l=Object.prototype.hasOwnProperty,G=(r,e)=>{for(var o in e)t(r,o,{get:e[o],enumerable:!0})},n=(r,e,o,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of P(e))!l.call(r,s)&&s!==o&&t(r,s,{get:()=>e[s],enumerable:!(i=y(e,s))||i.enumerable});return r},R=(r,e,o)=>(o=r!=null?I(g(r)):{},n(e||!r||!r.__esModule?t(o,"default",{value:r,enumerable:!0}):o,r)),S=r=>n(t({},"__esModule",{value:!0}),r),k={};G(k,{handler:()=>f}),module.exports=S(k);var a=R(require("@aws-sdk/client-ec2")),u=new a.EC2({});function c(r,e){return{GroupId:r,IpPermissions:[{UserIdGroupPairs:[{GroupId:r,UserId:e}],IpProtocol:"-1"}]}}function d(r){return{GroupId:r,IpPermissions:[{IpRanges:[{CidrIp:"0.0.0.0/0"}],IpProtocol:"-1"}]}}async function f(r){let e=r.ResourceProperties.DefaultSecurityGroupId,o=r.ResourceProperties.Account;switch(r.RequestType){case"Create":return p(e,o);case"Update":return h(r);case"Delete":return m(e,o)}}async function h(r){let e=r.OldResourceProperties.DefaultSecurityGroupId,o=r.ResourceProperties.DefaultSecurityGroupId;e!==o&&(await m(e,r.ResourceProperties.Account),await p(o,r.ResourceProperties.Account))}async function p(r,e){try{await u.revokeSecurityGroupEgress(d(r))}catch(o){if(o.name!=="InvalidPermission.NotFound")throw o}try{await u.revokeSecurityGroupIngress(c(r,e))}catch(o){if(o.name!=="InvalidPermission.NotFound")throw o}}async function m(r,e){await u.authorizeSecurityGroupIngress(c(r,e)),await u.authorizeSecurityGroupEgress(d(r))} diff --git a/test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/cdk.out b/test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/cdk.out new file mode 100644 index 0000000..1f0068d --- /dev/null +++ b/test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"36.0.0"} \ No newline at end of file diff --git a/test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/integ.json b/test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/integ.json new file mode 100644 index 0000000..f751515 --- /dev/null +++ b/test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/integ.json @@ -0,0 +1,12 @@ +{ + "version": "36.0.0", + "testCases": { + "InstanceConnectEndpoint/DefaultTest": { + "stacks": [ + "InstanceConnectEndpointStack" + ], + "assertionStack": "InstanceConnectEndpoint/DefaultTest/DeployAssert", + "assertionStackName": "InstanceConnectEndpointDefaultTestDeployAssert284B1FD7" + } + } +} \ No newline at end of file diff --git a/test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/manifest.json b/test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/manifest.json new file mode 100644 index 0000000..4d8b280 --- /dev/null +++ b/test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/manifest.json @@ -0,0 +1,317 @@ +{ + "version": "36.0.0", + "artifacts": { + "InstanceConnectEndpointStack.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "InstanceConnectEndpointStack.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "InstanceConnectEndpointStack": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "InstanceConnectEndpointStack.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/0c30d0501af434d3551d71e0423d0b989083d4d2f748dfae2cd738cc08f4c904.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "InstanceConnectEndpointStack.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "InstanceConnectEndpointStack.assets" + ], + "metadata": { + "/InstanceConnectEndpointStack/VPC/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCB9E5F0B4" + } + ], + "/InstanceConnectEndpointStack/VPC/PublicSubnet1/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet1SubnetB4246D30" + } + ], + "/InstanceConnectEndpointStack/VPC/PublicSubnet1/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet1RouteTableFEE4B781" + } + ], + "/InstanceConnectEndpointStack/VPC/PublicSubnet1/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet1RouteTableAssociation0B0896DC" + } + ], + "/InstanceConnectEndpointStack/VPC/PublicSubnet1/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet1DefaultRoute91CEF279" + } + ], + "/InstanceConnectEndpointStack/VPC/PublicSubnet1/EIP": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet1EIP6AD938E8" + } + ], + "/InstanceConnectEndpointStack/VPC/PublicSubnet1/NATGateway": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet1NATGatewayE0556630" + } + ], + "/InstanceConnectEndpointStack/VPC/PublicSubnet2/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet2Subnet74179F39" + } + ], + "/InstanceConnectEndpointStack/VPC/PublicSubnet2/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet2RouteTable6F1A15F1" + } + ], + "/InstanceConnectEndpointStack/VPC/PublicSubnet2/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet2RouteTableAssociation5A808732" + } + ], + "/InstanceConnectEndpointStack/VPC/PublicSubnet2/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet2DefaultRouteB7481BBA" + } + ], + "/InstanceConnectEndpointStack/VPC/PublicSubnet2/EIP": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet2EIP4947BC00" + } + ], + "/InstanceConnectEndpointStack/VPC/PublicSubnet2/NATGateway": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPublicSubnet2NATGateway3C070193" + } + ], + "/InstanceConnectEndpointStack/VPC/PrivateSubnet1/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPrivateSubnet1Subnet8BCA10E0" + } + ], + "/InstanceConnectEndpointStack/VPC/PrivateSubnet1/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPrivateSubnet1RouteTableBE8A6027" + } + ], + "/InstanceConnectEndpointStack/VPC/PrivateSubnet1/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPrivateSubnet1RouteTableAssociation347902D1" + } + ], + "/InstanceConnectEndpointStack/VPC/PrivateSubnet1/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPrivateSubnet1DefaultRouteAE1D6490" + } + ], + "/InstanceConnectEndpointStack/VPC/PrivateSubnet2/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPrivateSubnet2SubnetCFCDAA7A" + } + ], + "/InstanceConnectEndpointStack/VPC/PrivateSubnet2/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPrivateSubnet2RouteTable0A19E10E" + } + ], + "/InstanceConnectEndpointStack/VPC/PrivateSubnet2/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPrivateSubnet2RouteTableAssociation0C73D413" + } + ], + "/InstanceConnectEndpointStack/VPC/PrivateSubnet2/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCPrivateSubnet2DefaultRouteF4F5CFD2" + } + ], + "/InstanceConnectEndpointStack/VPC/IGW": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCIGWB7E252D3" + } + ], + "/InstanceConnectEndpointStack/VPC/VPCGW": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCVPCGW99B986DC" + } + ], + "/InstanceConnectEndpointStack/VPC/RestrictDefaultSecurityGroupCustomResource/Default": [ + { + "type": "aws:cdk:logicalId", + "data": "VPCRestrictDefaultSecurityGroupCustomResource59474679" + } + ], + "/InstanceConnectEndpointStack/Custom::VpcRestrictDefaultSGCustomResourceProvider/Role": [ + { + "type": "aws:cdk:logicalId", + "data": "CustomVpcRestrictDefaultSGCustomResourceProviderRole26592FE0" + } + ], + "/InstanceConnectEndpointStack/Custom::VpcRestrictDefaultSGCustomResourceProvider/Handler": [ + { + "type": "aws:cdk:logicalId", + "data": "CustomVpcRestrictDefaultSGCustomResourceProviderHandlerDC833E5E" + } + ], + "/InstanceConnectEndpointStack/Instance/InstanceSecurityGroup/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "InstanceInstanceSecurityGroupF0E2D5BE" + } + ], + "/InstanceConnectEndpointStack/Instance/InstanceSecurityGroup/from InstanceConnectEndpointStackSecurityGroupAB1BD525:22": [ + { + "type": "aws:cdk:logicalId", + "data": "InstanceInstanceSecurityGroupfromInstanceConnectEndpointStackSecurityGroupAB1BD525228343766C" + } + ], + "/InstanceConnectEndpointStack/Instance/InstanceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "InstanceInstanceRoleE9785DE5" + } + ], + "/InstanceConnectEndpointStack/Instance/InstanceProfile": [ + { + "type": "aws:cdk:logicalId", + "data": "InstanceInstanceProfileAB5AEF02" + } + ], + "/InstanceConnectEndpointStack/Instance/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "InstanceC1063A87" + } + ], + "/InstanceConnectEndpointStack/SsmParameterValue:--aws--service--ami-amazon-linux-latest--al2023-ami-kernel-6.1-x86_64:C96584B6-F00A-464E-AD19-53AFF4B05118.Parameter": [ + { + "type": "aws:cdk:logicalId", + "data": "SsmParameterValueawsserviceamiamazonlinuxlatestal2023amikernel61x8664C96584B6F00A464EAD1953AFF4B05118Parameter" + } + ], + "/InstanceConnectEndpointStack/SecurityGroup/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "SecurityGroupDD263621" + } + ], + "/InstanceConnectEndpointStack/SecurityGroup/to InstanceConnectEndpointStackInstanceInstanceSecurityGroupED8DD45C:22": [ + { + "type": "aws:cdk:logicalId", + "data": "SecurityGrouptoInstanceConnectEndpointStackInstanceInstanceSecurityGroupED8DD45C22FB84383F" + } + ], + "/InstanceConnectEndpointStack/InstanceConnectEndpoint/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "InstanceConnectEndpointAC315DCA" + } + ], + "/InstanceConnectEndpointStack/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/InstanceConnectEndpointStack/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "InstanceConnectEndpointStack" + }, + "InstanceConnectEndpointDefaultTestDeployAssert284B1FD7.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "InstanceConnectEndpointDefaultTestDeployAssert284B1FD7.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "InstanceConnectEndpointDefaultTestDeployAssert284B1FD7": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "InstanceConnectEndpointDefaultTestDeployAssert284B1FD7.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "InstanceConnectEndpointDefaultTestDeployAssert284B1FD7.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "InstanceConnectEndpointDefaultTestDeployAssert284B1FD7.assets" + ], + "metadata": { + "/InstanceConnectEndpoint/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/InstanceConnectEndpoint/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "InstanceConnectEndpoint/DefaultTest/DeployAssert" + }, + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } + } + } +} \ No newline at end of file diff --git a/test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/tree.json b/test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/tree.json new file mode 100644 index 0000000..6c8493c --- /dev/null +++ b/test/aws-ec2/integ.instance-connect-endpoint.ts.snapshot/tree.json @@ -0,0 +1,1098 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "InstanceConnectEndpointStack": { + "id": "InstanceConnectEndpointStack", + "path": "InstanceConnectEndpointStack", + "children": { + "VPC": { + "id": "VPC", + "path": "InstanceConnectEndpointStack/VPC", + "children": { + "Resource": { + "id": "Resource", + "path": "InstanceConnectEndpointStack/VPC/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::VPC", + "aws:cdk:cloudformation:props": { + "cidrBlock": "10.0.0.0/16", + "enableDnsHostnames": true, + "enableDnsSupport": true, + "instanceTenancy": "default", + "tags": [ + { + "key": "Name", + "value": "InstanceConnectEndpointStack/VPC" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnVPC", + "version": "2.120.0" + } + }, + "PublicSubnet1": { + "id": "PublicSubnet1", + "path": "InstanceConnectEndpointStack/VPC/PublicSubnet1", + "children": { + "Subnet": { + "id": "Subnet", + "path": "InstanceConnectEndpointStack/VPC/PublicSubnet1/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "availabilityZone": { + "Fn::Select": [ + 0, + { + "Fn::GetAZs": "" + } + ] + }, + "cidrBlock": "10.0.0.0/18", + "mapPublicIpOnLaunch": true, + "tags": [ + { + "key": "aws-cdk:subnet-name", + "value": "Public" + }, + { + "key": "aws-cdk:subnet-type", + "value": "Public" + }, + { + "key": "Name", + "value": "InstanceConnectEndpointStack/VPC/PublicSubnet1" + } + ], + "vpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", + "version": "2.120.0" + } + }, + "Acl": { + "id": "Acl", + "path": "InstanceConnectEndpointStack/VPC/PublicSubnet1/Acl", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "2.120.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "InstanceConnectEndpointStack/VPC/PublicSubnet1/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "InstanceConnectEndpointStack/VPC/PublicSubnet1" + } + ], + "vpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", + "version": "2.120.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "InstanceConnectEndpointStack/VPC/PublicSubnet1/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VPCPublicSubnet1RouteTableFEE4B781" + }, + "subnetId": { + "Ref": "VPCPublicSubnet1SubnetB4246D30" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnetRouteTableAssociation", + "version": "2.120.0" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "InstanceConnectEndpointStack/VPC/PublicSubnet1/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "destinationCidrBlock": "0.0.0.0/0", + "gatewayId": { + "Ref": "VPCIGWB7E252D3" + }, + "routeTableId": { + "Ref": "VPCPublicSubnet1RouteTableFEE4B781" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", + "version": "2.120.0" + } + }, + "EIP": { + "id": "EIP", + "path": "InstanceConnectEndpointStack/VPC/PublicSubnet1/EIP", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::EIP", + "aws:cdk:cloudformation:props": { + "domain": "vpc", + "tags": [ + { + "key": "Name", + "value": "InstanceConnectEndpointStack/VPC/PublicSubnet1" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnEIP", + "version": "2.120.0" + } + }, + "NATGateway": { + "id": "NATGateway", + "path": "InstanceConnectEndpointStack/VPC/PublicSubnet1/NATGateway", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::NatGateway", + "aws:cdk:cloudformation:props": { + "allocationId": { + "Fn::GetAtt": [ + "VPCPublicSubnet1EIP6AD938E8", + "AllocationId" + ] + }, + "subnetId": { + "Ref": "VPCPublicSubnet1SubnetB4246D30" + }, + "tags": [ + { + "key": "Name", + "value": "InstanceConnectEndpointStack/VPC/PublicSubnet1" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnNatGateway", + "version": "2.120.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.PublicSubnet", + "version": "2.120.0" + } + }, + "PublicSubnet2": { + "id": "PublicSubnet2", + "path": "InstanceConnectEndpointStack/VPC/PublicSubnet2", + "children": { + "Subnet": { + "id": "Subnet", + "path": "InstanceConnectEndpointStack/VPC/PublicSubnet2/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "availabilityZone": { + "Fn::Select": [ + 1, + { + "Fn::GetAZs": "" + } + ] + }, + "cidrBlock": "10.0.64.0/18", + "mapPublicIpOnLaunch": true, + "tags": [ + { + "key": "aws-cdk:subnet-name", + "value": "Public" + }, + { + "key": "aws-cdk:subnet-type", + "value": "Public" + }, + { + "key": "Name", + "value": "InstanceConnectEndpointStack/VPC/PublicSubnet2" + } + ], + "vpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", + "version": "2.120.0" + } + }, + "Acl": { + "id": "Acl", + "path": "InstanceConnectEndpointStack/VPC/PublicSubnet2/Acl", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "2.120.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "InstanceConnectEndpointStack/VPC/PublicSubnet2/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "InstanceConnectEndpointStack/VPC/PublicSubnet2" + } + ], + "vpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", + "version": "2.120.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "InstanceConnectEndpointStack/VPC/PublicSubnet2/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VPCPublicSubnet2RouteTable6F1A15F1" + }, + "subnetId": { + "Ref": "VPCPublicSubnet2Subnet74179F39" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnetRouteTableAssociation", + "version": "2.120.0" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "InstanceConnectEndpointStack/VPC/PublicSubnet2/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "destinationCidrBlock": "0.0.0.0/0", + "gatewayId": { + "Ref": "VPCIGWB7E252D3" + }, + "routeTableId": { + "Ref": "VPCPublicSubnet2RouteTable6F1A15F1" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", + "version": "2.120.0" + } + }, + "EIP": { + "id": "EIP", + "path": "InstanceConnectEndpointStack/VPC/PublicSubnet2/EIP", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::EIP", + "aws:cdk:cloudformation:props": { + "domain": "vpc", + "tags": [ + { + "key": "Name", + "value": "InstanceConnectEndpointStack/VPC/PublicSubnet2" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnEIP", + "version": "2.120.0" + } + }, + "NATGateway": { + "id": "NATGateway", + "path": "InstanceConnectEndpointStack/VPC/PublicSubnet2/NATGateway", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::NatGateway", + "aws:cdk:cloudformation:props": { + "allocationId": { + "Fn::GetAtt": [ + "VPCPublicSubnet2EIP4947BC00", + "AllocationId" + ] + }, + "subnetId": { + "Ref": "VPCPublicSubnet2Subnet74179F39" + }, + "tags": [ + { + "key": "Name", + "value": "InstanceConnectEndpointStack/VPC/PublicSubnet2" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnNatGateway", + "version": "2.120.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.PublicSubnet", + "version": "2.120.0" + } + }, + "PrivateSubnet1": { + "id": "PrivateSubnet1", + "path": "InstanceConnectEndpointStack/VPC/PrivateSubnet1", + "children": { + "Subnet": { + "id": "Subnet", + "path": "InstanceConnectEndpointStack/VPC/PrivateSubnet1/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "availabilityZone": { + "Fn::Select": [ + 0, + { + "Fn::GetAZs": "" + } + ] + }, + "cidrBlock": "10.0.128.0/18", + "mapPublicIpOnLaunch": false, + "tags": [ + { + "key": "aws-cdk:subnet-name", + "value": "Private" + }, + { + "key": "aws-cdk:subnet-type", + "value": "Private" + }, + { + "key": "Name", + "value": "InstanceConnectEndpointStack/VPC/PrivateSubnet1" + } + ], + "vpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", + "version": "2.120.0" + } + }, + "Acl": { + "id": "Acl", + "path": "InstanceConnectEndpointStack/VPC/PrivateSubnet1/Acl", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "2.120.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "InstanceConnectEndpointStack/VPC/PrivateSubnet1/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "InstanceConnectEndpointStack/VPC/PrivateSubnet1" + } + ], + "vpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", + "version": "2.120.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "InstanceConnectEndpointStack/VPC/PrivateSubnet1/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VPCPrivateSubnet1RouteTableBE8A6027" + }, + "subnetId": { + "Ref": "VPCPrivateSubnet1Subnet8BCA10E0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnetRouteTableAssociation", + "version": "2.120.0" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "InstanceConnectEndpointStack/VPC/PrivateSubnet1/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "destinationCidrBlock": "0.0.0.0/0", + "natGatewayId": { + "Ref": "VPCPublicSubnet1NATGatewayE0556630" + }, + "routeTableId": { + "Ref": "VPCPrivateSubnet1RouteTableBE8A6027" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", + "version": "2.120.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.PrivateSubnet", + "version": "2.120.0" + } + }, + "PrivateSubnet2": { + "id": "PrivateSubnet2", + "path": "InstanceConnectEndpointStack/VPC/PrivateSubnet2", + "children": { + "Subnet": { + "id": "Subnet", + "path": "InstanceConnectEndpointStack/VPC/PrivateSubnet2/Subnet", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Subnet", + "aws:cdk:cloudformation:props": { + "availabilityZone": { + "Fn::Select": [ + 1, + { + "Fn::GetAZs": "" + } + ] + }, + "cidrBlock": "10.0.192.0/18", + "mapPublicIpOnLaunch": false, + "tags": [ + { + "key": "aws-cdk:subnet-name", + "value": "Private" + }, + { + "key": "aws-cdk:subnet-type", + "value": "Private" + }, + { + "key": "Name", + "value": "InstanceConnectEndpointStack/VPC/PrivateSubnet2" + } + ], + "vpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", + "version": "2.120.0" + } + }, + "Acl": { + "id": "Acl", + "path": "InstanceConnectEndpointStack/VPC/PrivateSubnet2/Acl", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "2.120.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "InstanceConnectEndpointStack/VPC/PrivateSubnet2/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "InstanceConnectEndpointStack/VPC/PrivateSubnet2" + } + ], + "vpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", + "version": "2.120.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "InstanceConnectEndpointStack/VPC/PrivateSubnet2/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "VPCPrivateSubnet2RouteTable0A19E10E" + }, + "subnetId": { + "Ref": "VPCPrivateSubnet2SubnetCFCDAA7A" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnetRouteTableAssociation", + "version": "2.120.0" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "InstanceConnectEndpointStack/VPC/PrivateSubnet2/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "destinationCidrBlock": "0.0.0.0/0", + "natGatewayId": { + "Ref": "VPCPublicSubnet2NATGateway3C070193" + }, + "routeTableId": { + "Ref": "VPCPrivateSubnet2RouteTable0A19E10E" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", + "version": "2.120.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.PrivateSubnet", + "version": "2.120.0" + } + }, + "IGW": { + "id": "IGW", + "path": "InstanceConnectEndpointStack/VPC/IGW", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::InternetGateway", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "InstanceConnectEndpointStack/VPC" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnInternetGateway", + "version": "2.120.0" + } + }, + "VPCGW": { + "id": "VPCGW", + "path": "InstanceConnectEndpointStack/VPC/VPCGW", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::VPCGatewayAttachment", + "aws:cdk:cloudformation:props": { + "internetGatewayId": { + "Ref": "VPCIGWB7E252D3" + }, + "vpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnVPCGatewayAttachment", + "version": "2.120.0" + } + }, + "RestrictDefaultSecurityGroupCustomResource": { + "id": "RestrictDefaultSecurityGroupCustomResource", + "path": "InstanceConnectEndpointStack/VPC/RestrictDefaultSecurityGroupCustomResource", + "children": { + "Default": { + "id": "Default", + "path": "InstanceConnectEndpointStack/VPC/RestrictDefaultSecurityGroupCustomResource/Default", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnResource", + "version": "2.120.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.CustomResource", + "version": "2.120.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.Vpc", + "version": "2.120.0" + } + }, + "Custom::VpcRestrictDefaultSGCustomResourceProvider": { + "id": "Custom::VpcRestrictDefaultSGCustomResourceProvider", + "path": "InstanceConnectEndpointStack/Custom::VpcRestrictDefaultSGCustomResourceProvider", + "children": { + "Staging": { + "id": "Staging", + "path": "InstanceConnectEndpointStack/Custom::VpcRestrictDefaultSGCustomResourceProvider/Staging", + "constructInfo": { + "fqn": "aws-cdk-lib.AssetStaging", + "version": "2.120.0" + } + }, + "Role": { + "id": "Role", + "path": "InstanceConnectEndpointStack/Custom::VpcRestrictDefaultSGCustomResourceProvider/Role", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnResource", + "version": "2.120.0" + } + }, + "Handler": { + "id": "Handler", + "path": "InstanceConnectEndpointStack/Custom::VpcRestrictDefaultSGCustomResourceProvider/Handler", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnResource", + "version": "2.120.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.CustomResourceProviderBase", + "version": "2.120.0" + } + }, + "Instance": { + "id": "Instance", + "path": "InstanceConnectEndpointStack/Instance", + "children": { + "InstanceSecurityGroup": { + "id": "InstanceSecurityGroup", + "path": "InstanceConnectEndpointStack/Instance/InstanceSecurityGroup", + "children": { + "Resource": { + "id": "Resource", + "path": "InstanceConnectEndpointStack/Instance/InstanceSecurityGroup/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SecurityGroup", + "aws:cdk:cloudformation:props": { + "groupDescription": "InstanceConnectEndpointStack/Instance/InstanceSecurityGroup", + "securityGroupEgress": [ + { + "cidrIp": "0.0.0.0/0", + "description": "Allow all outbound traffic by default", + "ipProtocol": "-1" + } + ], + "tags": [ + { + "key": "Name", + "value": "InstanceConnectEndpointStack/Instance" + } + ], + "vpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSecurityGroup", + "version": "2.120.0" + } + }, + "from InstanceConnectEndpointStackSecurityGroupAB1BD525:22": { + "id": "from InstanceConnectEndpointStackSecurityGroupAB1BD525:22", + "path": "InstanceConnectEndpointStack/Instance/InstanceSecurityGroup/from InstanceConnectEndpointStackSecurityGroupAB1BD525:22", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SecurityGroupIngress", + "aws:cdk:cloudformation:props": { + "description": "from InstanceConnectEndpointStackSecurityGroupAB1BD525:22", + "fromPort": 22, + "groupId": { + "Fn::GetAtt": [ + "InstanceInstanceSecurityGroupF0E2D5BE", + "GroupId" + ] + }, + "ipProtocol": "tcp", + "sourceSecurityGroupId": { + "Fn::GetAtt": [ + "SecurityGroupDD263621", + "GroupId" + ] + }, + "toPort": 22 + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSecurityGroupIngress", + "version": "2.120.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.SecurityGroup", + "version": "2.120.0" + } + }, + "InstanceRole": { + "id": "InstanceRole", + "path": "InstanceConnectEndpointStack/Instance/InstanceRole", + "children": { + "ImportInstanceRole": { + "id": "ImportInstanceRole", + "path": "InstanceConnectEndpointStack/Instance/InstanceRole/ImportInstanceRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "2.120.0" + } + }, + "Resource": { + "id": "Resource", + "path": "InstanceConnectEndpointStack/Instance/InstanceRole/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "ec2.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "tags": [ + { + "key": "Name", + "value": "InstanceConnectEndpointStack/Instance" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnRole", + "version": "2.120.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "2.120.0" + } + }, + "InstanceProfile": { + "id": "InstanceProfile", + "path": "InstanceConnectEndpointStack/Instance/InstanceProfile", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::InstanceProfile", + "aws:cdk:cloudformation:props": { + "roles": [ + { + "Ref": "InstanceInstanceRoleE9785DE5" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnInstanceProfile", + "version": "2.120.0" + } + }, + "Resource": { + "id": "Resource", + "path": "InstanceConnectEndpointStack/Instance/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Instance", + "aws:cdk:cloudformation:props": { + "availabilityZone": { + "Fn::Select": [ + 0, + { + "Fn::GetAZs": "" + } + ] + }, + "iamInstanceProfile": { + "Ref": "InstanceInstanceProfileAB5AEF02" + }, + "imageId": { + "Ref": "SsmParameterValueawsserviceamiamazonlinuxlatestal2023amikernel61x8664C96584B6F00A464EAD1953AFF4B05118Parameter" + }, + "instanceType": "c5.large", + "securityGroupIds": [ + { + "Fn::GetAtt": [ + "InstanceInstanceSecurityGroupF0E2D5BE", + "GroupId" + ] + } + ], + "subnetId": { + "Ref": "VPCPrivateSubnet1Subnet8BCA10E0" + }, + "tags": [ + { + "key": "Name", + "value": "InstanceConnectEndpointStack/Instance" + } + ], + "userData": { + "Fn::Base64": "#!/bin/bash" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnInstance", + "version": "2.120.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.Instance", + "version": "2.120.0" + } + }, + "SsmParameterValue:--aws--service--ami-amazon-linux-latest--al2023-ami-kernel-6.1-x86_64:C96584B6-F00A-464E-AD19-53AFF4B05118.Parameter": { + "id": "SsmParameterValue:--aws--service--ami-amazon-linux-latest--al2023-ami-kernel-6.1-x86_64:C96584B6-F00A-464E-AD19-53AFF4B05118.Parameter", + "path": "InstanceConnectEndpointStack/SsmParameterValue:--aws--service--ami-amazon-linux-latest--al2023-ami-kernel-6.1-x86_64:C96584B6-F00A-464E-AD19-53AFF4B05118.Parameter", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "2.120.0" + } + }, + "SsmParameterValue:--aws--service--ami-amazon-linux-latest--al2023-ami-kernel-6.1-x86_64:C96584B6-F00A-464E-AD19-53AFF4B05118": { + "id": "SsmParameterValue:--aws--service--ami-amazon-linux-latest--al2023-ami-kernel-6.1-x86_64:C96584B6-F00A-464E-AD19-53AFF4B05118", + "path": "InstanceConnectEndpointStack/SsmParameterValue:--aws--service--ami-amazon-linux-latest--al2023-ami-kernel-6.1-x86_64:C96584B6-F00A-464E-AD19-53AFF4B05118", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "2.120.0" + } + }, + "SecurityGroup": { + "id": "SecurityGroup", + "path": "InstanceConnectEndpointStack/SecurityGroup", + "children": { + "Resource": { + "id": "Resource", + "path": "InstanceConnectEndpointStack/SecurityGroup/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SecurityGroup", + "aws:cdk:cloudformation:props": { + "groupDescription": "InstanceConnectEndpointStack/SecurityGroup", + "vpcId": { + "Ref": "VPCB9E5F0B4" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSecurityGroup", + "version": "2.120.0" + } + }, + "to InstanceConnectEndpointStackInstanceInstanceSecurityGroupED8DD45C:22": { + "id": "to InstanceConnectEndpointStackInstanceInstanceSecurityGroupED8DD45C:22", + "path": "InstanceConnectEndpointStack/SecurityGroup/to InstanceConnectEndpointStackInstanceInstanceSecurityGroupED8DD45C:22", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SecurityGroupEgress", + "aws:cdk:cloudformation:props": { + "description": "to InstanceConnectEndpointStackInstanceInstanceSecurityGroupED8DD45C:22", + "destinationSecurityGroupId": { + "Fn::GetAtt": [ + "InstanceInstanceSecurityGroupF0E2D5BE", + "GroupId" + ] + }, + "fromPort": 22, + "groupId": { + "Fn::GetAtt": [ + "SecurityGroupDD263621", + "GroupId" + ] + }, + "ipProtocol": "tcp", + "toPort": 22 + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSecurityGroupEgress", + "version": "2.120.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.SecurityGroup", + "version": "2.120.0" + } + }, + "InstanceConnectEndpoint": { + "id": "InstanceConnectEndpoint", + "path": "InstanceConnectEndpointStack/InstanceConnectEndpoint", + "children": { + "Resource": { + "id": "Resource", + "path": "InstanceConnectEndpointStack/InstanceConnectEndpoint/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::InstanceConnectEndpoint", + "aws:cdk:cloudformation:props": { + "clientToken": "my-client-token", + "preserveClientIp": true, + "securityGroupIds": [ + { + "Fn::GetAtt": [ + "SecurityGroupDD263621", + "GroupId" + ] + } + ], + "subnetId": { + "Ref": "VPCPrivateSubnet1Subnet8BCA10E0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnInstanceConnectEndpoint", + "version": "2.120.0" + } + } + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "InstanceConnectEndpointStack/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "2.120.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "InstanceConnectEndpointStack/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "2.120.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "2.120.0" + } + }, + "InstanceConnectEndpoint": { + "id": "InstanceConnectEndpoint", + "path": "InstanceConnectEndpoint", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "InstanceConnectEndpoint/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "InstanceConnectEndpoint/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "InstanceConnectEndpoint/DefaultTest/DeployAssert", + "children": { + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "InstanceConnectEndpoint/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "2.120.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "InstanceConnectEndpoint/DefaultTest/DeployAssert/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "2.120.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "2.120.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTestCase", + "version": "2.120.0-alpha.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTest", + "version": "2.120.0-alpha.0" + } + }, + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.App", + "version": "2.120.0" + } + } +} \ No newline at end of file