From a29bf19be1e17c13b85f6edd45c382c1f0d89702 Mon Sep 17 00:00:00 2001 From: Michelle Wang <88697971+michelle-wangg@users.noreply.github.com> Date: Mon, 23 Sep 2024 17:13:52 -0700 Subject: [PATCH] fix(ec2): instance resourceSignalTimeout overwrites initOptions.timeout (#31446) ### Issue # (if applicable) Closes #30052 ### Reason for this change When specifiying both `resourceSignalTimeout` and `initOptions.timeout` in the options for creating an EC2 Instance, only the value from `resourceSignalTimeout` is used. ### Description of changes - If both `initOptions.timeout` and `resourceSignalTimeout` are set, timeout consisting of the sum of the values and a warning suggesting that only one field should be specified - Else, timeout is set to field specified, else defaults to 5 min ### Description of how you validated changes - Update integration test for `instance-init.js` with both fields and verify that warning is logged - Add unit tests: - `initOptions.timeout` and `resourceSignalTimeout` are both not set, timeout is set to default of 5 min - `initOptions.timeout` set and `resourceSignalTimeout` not set, timeout is set to initOptions.timeout - `initOptions.timeout` not set and `resourceSignalTimeout` is set, timeout is set to `resourceSignalTimeout` - `initOptions.timeout` and `resourceSignalTimeout` are both set, timeout is set to sum of timeouts and warning is logged ### Checklist - [ ] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- ...efaultTestDeployAssert5CD5B9B5.assets.json | 19 + ...aultTestDeployAssert5CD5B9B5.template.json | 36 + .../testFile | 1 + .../cdk.out | 1 + .../integ-init.assets.json | 32 + .../integ-init.template.json | 718 +++++++++++ .../integ.json | 12 + .../manifest.json | 287 +++++ .../tree.json | 1059 +++++++++++++++++ .../integ.enable-sum-timeout-instance-init.ts | 76 ++ .../integ.instance-init.js.snapshot/cdk.out | 2 +- ...efaultTestDeployAssert2123E149.assets.json | 19 + ...aultTestDeployAssert2123E149.template.json | 36 + .../integ-init.assets.json | 6 +- .../integ-init.template.json | 2 +- .../integ.json | 12 +- .../manifest.json | 57 +- .../integ.instance-init.js.snapshot/tree.json | 54 + .../test/aws-ec2/test/integ.instance-init.ts | 12 +- packages/aws-cdk-lib/aws-ec2/lib/instance.ts | 23 +- .../aws-cdk-lib/aws-ec2/test/instance.test.ts | 157 ++- packages/aws-cdk-lib/cx-api/FEATURE_FLAGS.md | 20 +- packages/aws-cdk-lib/cx-api/README.md | 16 + packages/aws-cdk-lib/cx-api/lib/features.ts | 15 + 24 files changed, 2646 insertions(+), 26 deletions(-) create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.js.snapshot/EnableSumTimeoutInstanceTestDefaultTestDeployAssert5CD5B9B5.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.js.snapshot/EnableSumTimeoutInstanceTestDefaultTestDeployAssert5CD5B9B5.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.js.snapshot/asset.f8a1af398dac2fad92eeea4fb7620be1c4f504e23e3bfcd859fbb5744187930b/testFile create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.js.snapshot/cdk.out create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.js.snapshot/integ-init.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.js.snapshot/integ-init.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.js.snapshot/integ.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.js.snapshot/manifest.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.js.snapshot/tree.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.ts create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.instance-init.js.snapshot/instanceinittestDefaultTestDeployAssert2123E149.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.instance-init.js.snapshot/instanceinittestDefaultTestDeployAssert2123E149.template.json diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.js.snapshot/EnableSumTimeoutInstanceTestDefaultTestDeployAssert5CD5B9B5.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.js.snapshot/EnableSumTimeoutInstanceTestDefaultTestDeployAssert5CD5B9B5.assets.json new file mode 100644 index 0000000000000..262dde293ef56 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.js.snapshot/EnableSumTimeoutInstanceTestDefaultTestDeployAssert5CD5B9B5.assets.json @@ -0,0 +1,19 @@ +{ + "version": "36.0.24", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "EnableSumTimeoutInstanceTestDefaultTestDeployAssert5CD5B9B5.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/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.js.snapshot/EnableSumTimeoutInstanceTestDefaultTestDeployAssert5CD5B9B5.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.js.snapshot/EnableSumTimeoutInstanceTestDefaultTestDeployAssert5CD5B9B5.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.js.snapshot/EnableSumTimeoutInstanceTestDefaultTestDeployAssert5CD5B9B5.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/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.js.snapshot/asset.f8a1af398dac2fad92eeea4fb7620be1c4f504e23e3bfcd859fbb5744187930b/testFile b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.js.snapshot/asset.f8a1af398dac2fad92eeea4fb7620be1c4f504e23e3bfcd859fbb5744187930b/testFile new file mode 100644 index 0000000000000..980a0d5f19a64 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.js.snapshot/asset.f8a1af398dac2fad92eeea4fb7620be1c4f504e23e3bfcd859fbb5744187930b/testFile @@ -0,0 +1 @@ +Hello World! diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.js.snapshot/cdk.out new file mode 100644 index 0000000000000..4efaa16f29af9 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.js.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"36.0.24"} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.js.snapshot/integ-init.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.js.snapshot/integ-init.assets.json new file mode 100644 index 0000000000000..9f3cec5827aaf --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.js.snapshot/integ-init.assets.json @@ -0,0 +1,32 @@ +{ + "version": "36.0.24", + "files": { + "f8a1af398dac2fad92eeea4fb7620be1c4f504e23e3bfcd859fbb5744187930b": { + "source": { + "path": "asset.f8a1af398dac2fad92eeea4fb7620be1c4f504e23e3bfcd859fbb5744187930b", + "packaging": "zip" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "f8a1af398dac2fad92eeea4fb7620be1c4f504e23e3bfcd859fbb5744187930b.zip", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + }, + "aabd2520799daa243ae9f17baf1ab61a81d22b69d172736ad387003b7fb81fdc": { + "source": { + "path": "integ-init.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "aabd2520799daa243ae9f17baf1ab61a81d22b69d172736ad387003b7fb81fdc.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/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.js.snapshot/integ-init.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.js.snapshot/integ-init.template.json new file mode 100644 index 0000000000000..4f5005352ab68 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.js.snapshot/integ-init.template.json @@ -0,0 +1,718 @@ +{ + "Resources": { + "IntegInitVpc0D4FCCB3": { + "Type": "AWS::EC2::VPC", + "Properties": { + "CidrBlock": "10.0.0.0/16", + "EnableDnsHostnames": true, + "EnableDnsSupport": true, + "InstanceTenancy": "default", + "Tags": [ + { + "Key": "Name", + "Value": "integ-init/IntegInitVpc" + } + ] + } + }, + "IntegInitVpcPublicSubnet1Subnet41A6F6D4": { + "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": "integ-init/IntegInitVpc/PublicSubnet1" + } + ], + "VpcId": { + "Ref": "IntegInitVpc0D4FCCB3" + } + } + }, + "IntegInitVpcPublicSubnet1RouteTable837CD5FB": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "integ-init/IntegInitVpc/PublicSubnet1" + } + ], + "VpcId": { + "Ref": "IntegInitVpc0D4FCCB3" + } + } + }, + "IntegInitVpcPublicSubnet1RouteTableAssociation00D33741": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "IntegInitVpcPublicSubnet1RouteTable837CD5FB" + }, + "SubnetId": { + "Ref": "IntegInitVpcPublicSubnet1Subnet41A6F6D4" + } + } + }, + "IntegInitVpcPublicSubnet1DefaultRoute5BB90E8C": { + "Type": "AWS::EC2::Route", + "Properties": { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": { + "Ref": "IntegInitVpcIGWF019AC85" + }, + "RouteTableId": { + "Ref": "IntegInitVpcPublicSubnet1RouteTable837CD5FB" + } + }, + "DependsOn": [ + "IntegInitVpcVPCGW85EDC292" + ] + }, + "IntegInitVpcPublicSubnet1EIP46FCC3D6": { + "Type": "AWS::EC2::EIP", + "Properties": { + "Domain": "vpc", + "Tags": [ + { + "Key": "Name", + "Value": "integ-init/IntegInitVpc/PublicSubnet1" + } + ] + } + }, + "IntegInitVpcPublicSubnet1NATGateway46F32F7F": { + "Type": "AWS::EC2::NatGateway", + "Properties": { + "AllocationId": { + "Fn::GetAtt": [ + "IntegInitVpcPublicSubnet1EIP46FCC3D6", + "AllocationId" + ] + }, + "SubnetId": { + "Ref": "IntegInitVpcPublicSubnet1Subnet41A6F6D4" + }, + "Tags": [ + { + "Key": "Name", + "Value": "integ-init/IntegInitVpc/PublicSubnet1" + } + ] + }, + "DependsOn": [ + "IntegInitVpcPublicSubnet1DefaultRoute5BB90E8C", + "IntegInitVpcPublicSubnet1RouteTableAssociation00D33741" + ] + }, + "IntegInitVpcPublicSubnet2Subnet9A384F16": { + "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": "integ-init/IntegInitVpc/PublicSubnet2" + } + ], + "VpcId": { + "Ref": "IntegInitVpc0D4FCCB3" + } + } + }, + "IntegInitVpcPublicSubnet2RouteTableF7E8F920": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "integ-init/IntegInitVpc/PublicSubnet2" + } + ], + "VpcId": { + "Ref": "IntegInitVpc0D4FCCB3" + } + } + }, + "IntegInitVpcPublicSubnet2RouteTableAssociationB816F9F3": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "IntegInitVpcPublicSubnet2RouteTableF7E8F920" + }, + "SubnetId": { + "Ref": "IntegInitVpcPublicSubnet2Subnet9A384F16" + } + } + }, + "IntegInitVpcPublicSubnet2DefaultRoute2393995F": { + "Type": "AWS::EC2::Route", + "Properties": { + "DestinationCidrBlock": "0.0.0.0/0", + "GatewayId": { + "Ref": "IntegInitVpcIGWF019AC85" + }, + "RouteTableId": { + "Ref": "IntegInitVpcPublicSubnet2RouteTableF7E8F920" + } + }, + "DependsOn": [ + "IntegInitVpcVPCGW85EDC292" + ] + }, + "IntegInitVpcPublicSubnet2EIP553B40DC": { + "Type": "AWS::EC2::EIP", + "Properties": { + "Domain": "vpc", + "Tags": [ + { + "Key": "Name", + "Value": "integ-init/IntegInitVpc/PublicSubnet2" + } + ] + } + }, + "IntegInitVpcPublicSubnet2NATGateway9CCB4A9C": { + "Type": "AWS::EC2::NatGateway", + "Properties": { + "AllocationId": { + "Fn::GetAtt": [ + "IntegInitVpcPublicSubnet2EIP553B40DC", + "AllocationId" + ] + }, + "SubnetId": { + "Ref": "IntegInitVpcPublicSubnet2Subnet9A384F16" + }, + "Tags": [ + { + "Key": "Name", + "Value": "integ-init/IntegInitVpc/PublicSubnet2" + } + ] + }, + "DependsOn": [ + "IntegInitVpcPublicSubnet2DefaultRoute2393995F", + "IntegInitVpcPublicSubnet2RouteTableAssociationB816F9F3" + ] + }, + "IntegInitVpcPrivateSubnet1Subnet259B51C1": { + "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": "integ-init/IntegInitVpc/PrivateSubnet1" + } + ], + "VpcId": { + "Ref": "IntegInitVpc0D4FCCB3" + } + } + }, + "IntegInitVpcPrivateSubnet1RouteTableCB37994B": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "integ-init/IntegInitVpc/PrivateSubnet1" + } + ], + "VpcId": { + "Ref": "IntegInitVpc0D4FCCB3" + } + } + }, + "IntegInitVpcPrivateSubnet1RouteTableAssociation067DEF9D": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "IntegInitVpcPrivateSubnet1RouteTableCB37994B" + }, + "SubnetId": { + "Ref": "IntegInitVpcPrivateSubnet1Subnet259B51C1" + } + } + }, + "IntegInitVpcPrivateSubnet1DefaultRoute654ACECF": { + "Type": "AWS::EC2::Route", + "Properties": { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": { + "Ref": "IntegInitVpcPublicSubnet1NATGateway46F32F7F" + }, + "RouteTableId": { + "Ref": "IntegInitVpcPrivateSubnet1RouteTableCB37994B" + } + } + }, + "IntegInitVpcPrivateSubnet2Subnet1643B059": { + "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": "integ-init/IntegInitVpc/PrivateSubnet2" + } + ], + "VpcId": { + "Ref": "IntegInitVpc0D4FCCB3" + } + } + }, + "IntegInitVpcPrivateSubnet2RouteTable030EC93B": { + "Type": "AWS::EC2::RouteTable", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "integ-init/IntegInitVpc/PrivateSubnet2" + } + ], + "VpcId": { + "Ref": "IntegInitVpc0D4FCCB3" + } + } + }, + "IntegInitVpcPrivateSubnet2RouteTableAssociation6B52BD72": { + "Type": "AWS::EC2::SubnetRouteTableAssociation", + "Properties": { + "RouteTableId": { + "Ref": "IntegInitVpcPrivateSubnet2RouteTable030EC93B" + }, + "SubnetId": { + "Ref": "IntegInitVpcPrivateSubnet2Subnet1643B059" + } + } + }, + "IntegInitVpcPrivateSubnet2DefaultRoute6A10B6EA": { + "Type": "AWS::EC2::Route", + "Properties": { + "DestinationCidrBlock": "0.0.0.0/0", + "NatGatewayId": { + "Ref": "IntegInitVpcPublicSubnet2NATGateway9CCB4A9C" + }, + "RouteTableId": { + "Ref": "IntegInitVpcPrivateSubnet2RouteTable030EC93B" + } + } + }, + "IntegInitVpcIGWF019AC85": { + "Type": "AWS::EC2::InternetGateway", + "Properties": { + "Tags": [ + { + "Key": "Name", + "Value": "integ-init/IntegInitVpc" + } + ] + } + }, + "IntegInitVpcVPCGW85EDC292": { + "Type": "AWS::EC2::VPCGatewayAttachment", + "Properties": { + "InternetGatewayId": { + "Ref": "IntegInitVpcIGWF019AC85" + }, + "VpcId": { + "Ref": "IntegInitVpc0D4FCCB3" + } + } + }, + "Instance2InstanceSecurityGroupC6129B1D": { + "Type": "AWS::EC2::SecurityGroup", + "Properties": { + "GroupDescription": "integ-init/Instance2/InstanceSecurityGroup", + "SecurityGroupEgress": [ + { + "CidrIp": "0.0.0.0/0", + "Description": "Allow all outbound traffic by default", + "IpProtocol": "-1" + } + ], + "Tags": [ + { + "Key": "Name", + "Value": "integ-init/Instance2" + } + ], + "VpcId": { + "Ref": "IntegInitVpc0D4FCCB3" + } + } + }, + "Instance2InstanceRole03DD7CB2": { + "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": "integ-init/Instance2" + } + ] + } + }, + "Instance2InstanceRoleDefaultPolicy610B37CD": { + "Type": "AWS::IAM::Policy", + "Properties": { + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "s3:GetBucket*", + "s3:GetObject*", + "s3:List*" + ], + "Effect": "Allow", + "Resource": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":s3:::", + { + "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" + }, + "/*" + ] + ] + }, + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":s3:::", + { + "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" + } + ] + ] + } + ] + }, + { + "Action": [ + "cloudformation:DescribeStackResource", + "cloudformation:SignalResource" + ], + "Effect": "Allow", + "Resource": { + "Ref": "AWS::StackId" + } + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "Instance2InstanceRoleDefaultPolicy610B37CD", + "Roles": [ + { + "Ref": "Instance2InstanceRole03DD7CB2" + } + ] + } + }, + "Instance2InstanceProfile582F915C": { + "Type": "AWS::IAM::InstanceProfile", + "Properties": { + "Roles": [ + { + "Ref": "Instance2InstanceRole03DD7CB2" + } + ] + } + }, + "Instance255F3526574cbd507dfce8b71": { + "Type": "AWS::EC2::Instance", + "Properties": { + "AvailabilityZone": { + "Fn::Select": [ + 0, + { + "Fn::GetAZs": "" + } + ] + }, + "IamInstanceProfile": { + "Ref": "Instance2InstanceProfile582F915C" + }, + "ImageId": { + "Ref": "SsmParameterValueawsserviceamiamazonlinuxlatestamznamihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter" + }, + "InstanceType": "t2.micro", + "SecurityGroupIds": [ + { + "Fn::GetAtt": [ + "Instance2InstanceSecurityGroupC6129B1D", + "GroupId" + ] + } + ], + "SubnetId": { + "Ref": "IntegInitVpcPublicSubnet1Subnet41A6F6D4" + }, + "Tags": [ + { + "Key": "Name", + "Value": "integ-init/Instance2" + } + ], + "UserData": { + "Fn::Base64": { + "Fn::Join": [ + "", + [ + "#!/bin/bash\n# fingerprint: 4f2827c68bde31b4\n(\n set +e\n /opt/aws/bin/cfn-init -v --region ", + { + "Ref": "AWS::Region" + }, + " --stack ", + { + "Ref": "AWS::StackName" + }, + " --resource Instance255F3526574cbd507dfce8b71 -c default\n /opt/aws/bin/cfn-signal -e $? --region ", + { + "Ref": "AWS::Region" + }, + " --stack ", + { + "Ref": "AWS::StackName" + }, + " --resource Instance255F3526574cbd507dfce8b71\n cat /var/log/cfn-init.log >&2\n)" + ] + ] + } + } + }, + "DependsOn": [ + "Instance2InstanceRoleDefaultPolicy610B37CD", + "Instance2InstanceRole03DD7CB2" + ], + "CreationPolicy": { + "ResourceSignal": { + "Count": 1, + "Timeout": "PT40M" + } + }, + "Metadata": { + "AWS::CloudFormation::Init": { + "configSets": { + "default": [ + "yumPreinstall", + "config" + ] + }, + "yumPreinstall": { + "packages": { + "yum": { + "git": [] + } + } + }, + "config": { + "groups": { + "group1": {}, + "group2": { + "gid": 42 + } + }, + "users": { + "sysuser1": { + "groups": [ + "group1", + "group2" + ], + "homeDir": "/home/sysuser1-custom" + }, + "sysuser2": {} + }, + "sources": { + "/tmp/sourceDir": { + "Fn::Sub": "https://s3.${AWS::Region}.${AWS::URLSuffix}/cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/f8a1af398dac2fad92eeea4fb7620be1c4f504e23e3bfcd859fbb5744187930b.zip" + } + }, + "files": { + "/tmp/file2.json": { + "content": { + "stackId": { + "Ref": "AWS::StackId" + }, + "stackName": "integ-init", + "region": { + "Ref": "AWS::Region" + }, + "intProperty": 18, + "boolProperty": true, + "numProperty": 58.23 + }, + "mode": "000644", + "owner": "root", + "group": "root" + } + } + }, + "service": { + "files": { + "/myvars.env": { + "content": "OTHER_VAR=\"im from the file :3\"", + "encoding": "plain", + "mode": "000644", + "owner": "root", + "group": "root" + }, + "/etc/systemd/system/myapp.service": { + "content": "[Unit]\nAfter=network.target\n[Service]\nExecStart=/bin/bash -c \"echo HELLO_WORLD=${MY_VAR} | FROM_FILE=${OTHER_VAR}\"\nRestart=always\nEnvironmentFile=/myvars.env\nEnvironment=\"MY_VAR=its me :)\"\n[Install]\nWantedBy=multi-user.target", + "encoding": "plain", + "mode": "000644", + "owner": "root", + "group": "root" + } + } + } + }, + "AWS::CloudFormation::Authentication": { + "S3AccessCreds": { + "type": "S3", + "roleName": { + "Ref": "Instance2InstanceRole03DD7CB2" + }, + "buckets": [ + { + "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" + } + ] + } + } + } + } + }, + "Parameters": { + "SsmParameterValueawsserviceamiamazonlinuxlatestamznamihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/aws/service/ami-amazon-linux-latest/amzn-ami-hvm-x86_64-gp2" + }, + "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/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.js.snapshot/integ.json new file mode 100644 index 0000000000000..e0c641fe0b9fe --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.js.snapshot/integ.json @@ -0,0 +1,12 @@ +{ + "version": "36.0.24", + "testCases": { + "EnableSumTimeoutInstanceTest/DefaultTest": { + "stacks": [ + "integ-init" + ], + "assertionStack": "EnableSumTimeoutInstanceTest/DefaultTest/DeployAssert", + "assertionStackName": "EnableSumTimeoutInstanceTestDefaultTestDeployAssert5CD5B9B5" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.js.snapshot/manifest.json new file mode 100644 index 0000000000000..9a3e37da8233b --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.js.snapshot/manifest.json @@ -0,0 +1,287 @@ +{ + "version": "36.0.24", + "artifacts": { + "integ-init.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "integ-init.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "integ-init": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "integ-init.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}/aabd2520799daa243ae9f17baf1ab61a81d22b69d172736ad387003b7fb81fdc.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "integ-init.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": [ + "integ-init.assets" + ], + "metadata": { + "/integ-init/IntegInitVpc/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "IntegInitVpc0D4FCCB3" + } + ], + "/integ-init/IntegInitVpc/PublicSubnet1/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "IntegInitVpcPublicSubnet1Subnet41A6F6D4" + } + ], + "/integ-init/IntegInitVpc/PublicSubnet1/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "IntegInitVpcPublicSubnet1RouteTable837CD5FB" + } + ], + "/integ-init/IntegInitVpc/PublicSubnet1/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "IntegInitVpcPublicSubnet1RouteTableAssociation00D33741" + } + ], + "/integ-init/IntegInitVpc/PublicSubnet1/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "IntegInitVpcPublicSubnet1DefaultRoute5BB90E8C" + } + ], + "/integ-init/IntegInitVpc/PublicSubnet1/EIP": [ + { + "type": "aws:cdk:logicalId", + "data": "IntegInitVpcPublicSubnet1EIP46FCC3D6" + } + ], + "/integ-init/IntegInitVpc/PublicSubnet1/NATGateway": [ + { + "type": "aws:cdk:logicalId", + "data": "IntegInitVpcPublicSubnet1NATGateway46F32F7F" + } + ], + "/integ-init/IntegInitVpc/PublicSubnet2/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "IntegInitVpcPublicSubnet2Subnet9A384F16" + } + ], + "/integ-init/IntegInitVpc/PublicSubnet2/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "IntegInitVpcPublicSubnet2RouteTableF7E8F920" + } + ], + "/integ-init/IntegInitVpc/PublicSubnet2/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "IntegInitVpcPublicSubnet2RouteTableAssociationB816F9F3" + } + ], + "/integ-init/IntegInitVpc/PublicSubnet2/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "IntegInitVpcPublicSubnet2DefaultRoute2393995F" + } + ], + "/integ-init/IntegInitVpc/PublicSubnet2/EIP": [ + { + "type": "aws:cdk:logicalId", + "data": "IntegInitVpcPublicSubnet2EIP553B40DC" + } + ], + "/integ-init/IntegInitVpc/PublicSubnet2/NATGateway": [ + { + "type": "aws:cdk:logicalId", + "data": "IntegInitVpcPublicSubnet2NATGateway9CCB4A9C" + } + ], + "/integ-init/IntegInitVpc/PrivateSubnet1/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "IntegInitVpcPrivateSubnet1Subnet259B51C1" + } + ], + "/integ-init/IntegInitVpc/PrivateSubnet1/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "IntegInitVpcPrivateSubnet1RouteTableCB37994B" + } + ], + "/integ-init/IntegInitVpc/PrivateSubnet1/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "IntegInitVpcPrivateSubnet1RouteTableAssociation067DEF9D" + } + ], + "/integ-init/IntegInitVpc/PrivateSubnet1/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "IntegInitVpcPrivateSubnet1DefaultRoute654ACECF" + } + ], + "/integ-init/IntegInitVpc/PrivateSubnet2/Subnet": [ + { + "type": "aws:cdk:logicalId", + "data": "IntegInitVpcPrivateSubnet2Subnet1643B059" + } + ], + "/integ-init/IntegInitVpc/PrivateSubnet2/RouteTable": [ + { + "type": "aws:cdk:logicalId", + "data": "IntegInitVpcPrivateSubnet2RouteTable030EC93B" + } + ], + "/integ-init/IntegInitVpc/PrivateSubnet2/RouteTableAssociation": [ + { + "type": "aws:cdk:logicalId", + "data": "IntegInitVpcPrivateSubnet2RouteTableAssociation6B52BD72" + } + ], + "/integ-init/IntegInitVpc/PrivateSubnet2/DefaultRoute": [ + { + "type": "aws:cdk:logicalId", + "data": "IntegInitVpcPrivateSubnet2DefaultRoute6A10B6EA" + } + ], + "/integ-init/IntegInitVpc/IGW": [ + { + "type": "aws:cdk:logicalId", + "data": "IntegInitVpcIGWF019AC85" + } + ], + "/integ-init/IntegInitVpc/VPCGW": [ + { + "type": "aws:cdk:logicalId", + "data": "IntegInitVpcVPCGW85EDC292" + } + ], + "/integ-init/Instance2": [ + { + "type": "aws:cdk:warning", + "data": "Both initOptions.timeout and resourceSignalTimeout fields are set, timeout is summed together. It is suggested that only one of the two fields is set [ack: @aws-cdk/aws-ec2:setSetimeout]" + } + ], + "/integ-init/Instance2/InstanceSecurityGroup/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "Instance2InstanceSecurityGroupC6129B1D" + } + ], + "/integ-init/Instance2/InstanceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "Instance2InstanceRole03DD7CB2" + } + ], + "/integ-init/Instance2/InstanceRole/DefaultPolicy/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "Instance2InstanceRoleDefaultPolicy610B37CD" + } + ], + "/integ-init/Instance2/InstanceProfile": [ + { + "type": "aws:cdk:logicalId", + "data": "Instance2InstanceProfile582F915C" + } + ], + "/integ-init/Instance2/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "Instance255F3526574cbd507dfce8b71" + } + ], + "/integ-init/SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn-ami-hvm-x86_64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118.Parameter": [ + { + "type": "aws:cdk:logicalId", + "data": "SsmParameterValueawsserviceamiamazonlinuxlatestamznamihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter" + } + ], + "/integ-init/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/integ-init/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "integ-init" + }, + "EnableSumTimeoutInstanceTestDefaultTestDeployAssert5CD5B9B5.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "EnableSumTimeoutInstanceTestDefaultTestDeployAssert5CD5B9B5.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "EnableSumTimeoutInstanceTestDefaultTestDeployAssert5CD5B9B5": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "EnableSumTimeoutInstanceTestDefaultTestDeployAssert5CD5B9B5.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": [ + "EnableSumTimeoutInstanceTestDefaultTestDeployAssert5CD5B9B5.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": [ + "EnableSumTimeoutInstanceTestDefaultTestDeployAssert5CD5B9B5.assets" + ], + "metadata": { + "/EnableSumTimeoutInstanceTest/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/EnableSumTimeoutInstanceTest/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "EnableSumTimeoutInstanceTest/DefaultTest/DeployAssert" + }, + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.js.snapshot/tree.json new file mode 100644 index 0000000000000..45613557829c5 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.js.snapshot/tree.json @@ -0,0 +1,1059 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "integ-init": { + "id": "integ-init", + "path": "integ-init", + "children": { + "IntegInitVpc": { + "id": "IntegInitVpc", + "path": "integ-init/IntegInitVpc", + "children": { + "Resource": { + "id": "Resource", + "path": "integ-init/IntegInitVpc/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": "integ-init/IntegInitVpc" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnVPC", + "version": "0.0.0" + } + }, + "PublicSubnet1": { + "id": "PublicSubnet1", + "path": "integ-init/IntegInitVpc/PublicSubnet1", + "children": { + "Subnet": { + "id": "Subnet", + "path": "integ-init/IntegInitVpc/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": "integ-init/IntegInitVpc/PublicSubnet1" + } + ], + "vpcId": { + "Ref": "IntegInitVpc0D4FCCB3" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "integ-init/IntegInitVpc/PublicSubnet1/Acl", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "integ-init/IntegInitVpc/PublicSubnet1/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "integ-init/IntegInitVpc/PublicSubnet1" + } + ], + "vpcId": { + "Ref": "IntegInitVpc0D4FCCB3" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "integ-init/IntegInitVpc/PublicSubnet1/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "IntegInitVpcPublicSubnet1RouteTable837CD5FB" + }, + "subnetId": { + "Ref": "IntegInitVpcPublicSubnet1Subnet41A6F6D4" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnetRouteTableAssociation", + "version": "0.0.0" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "integ-init/IntegInitVpc/PublicSubnet1/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "destinationCidrBlock": "0.0.0.0/0", + "gatewayId": { + "Ref": "IntegInitVpcIGWF019AC85" + }, + "routeTableId": { + "Ref": "IntegInitVpcPublicSubnet1RouteTable837CD5FB" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", + "version": "0.0.0" + } + }, + "EIP": { + "id": "EIP", + "path": "integ-init/IntegInitVpc/PublicSubnet1/EIP", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::EIP", + "aws:cdk:cloudformation:props": { + "domain": "vpc", + "tags": [ + { + "key": "Name", + "value": "integ-init/IntegInitVpc/PublicSubnet1" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnEIP", + "version": "0.0.0" + } + }, + "NATGateway": { + "id": "NATGateway", + "path": "integ-init/IntegInitVpc/PublicSubnet1/NATGateway", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::NatGateway", + "aws:cdk:cloudformation:props": { + "allocationId": { + "Fn::GetAtt": [ + "IntegInitVpcPublicSubnet1EIP46FCC3D6", + "AllocationId" + ] + }, + "subnetId": { + "Ref": "IntegInitVpcPublicSubnet1Subnet41A6F6D4" + }, + "tags": [ + { + "key": "Name", + "value": "integ-init/IntegInitVpc/PublicSubnet1" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnNatGateway", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.PublicSubnet", + "version": "0.0.0" + } + }, + "PublicSubnet2": { + "id": "PublicSubnet2", + "path": "integ-init/IntegInitVpc/PublicSubnet2", + "children": { + "Subnet": { + "id": "Subnet", + "path": "integ-init/IntegInitVpc/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": "integ-init/IntegInitVpc/PublicSubnet2" + } + ], + "vpcId": { + "Ref": "IntegInitVpc0D4FCCB3" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "integ-init/IntegInitVpc/PublicSubnet2/Acl", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "integ-init/IntegInitVpc/PublicSubnet2/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "integ-init/IntegInitVpc/PublicSubnet2" + } + ], + "vpcId": { + "Ref": "IntegInitVpc0D4FCCB3" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "integ-init/IntegInitVpc/PublicSubnet2/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "IntegInitVpcPublicSubnet2RouteTableF7E8F920" + }, + "subnetId": { + "Ref": "IntegInitVpcPublicSubnet2Subnet9A384F16" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnetRouteTableAssociation", + "version": "0.0.0" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "integ-init/IntegInitVpc/PublicSubnet2/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "destinationCidrBlock": "0.0.0.0/0", + "gatewayId": { + "Ref": "IntegInitVpcIGWF019AC85" + }, + "routeTableId": { + "Ref": "IntegInitVpcPublicSubnet2RouteTableF7E8F920" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", + "version": "0.0.0" + } + }, + "EIP": { + "id": "EIP", + "path": "integ-init/IntegInitVpc/PublicSubnet2/EIP", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::EIP", + "aws:cdk:cloudformation:props": { + "domain": "vpc", + "tags": [ + { + "key": "Name", + "value": "integ-init/IntegInitVpc/PublicSubnet2" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnEIP", + "version": "0.0.0" + } + }, + "NATGateway": { + "id": "NATGateway", + "path": "integ-init/IntegInitVpc/PublicSubnet2/NATGateway", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::NatGateway", + "aws:cdk:cloudformation:props": { + "allocationId": { + "Fn::GetAtt": [ + "IntegInitVpcPublicSubnet2EIP553B40DC", + "AllocationId" + ] + }, + "subnetId": { + "Ref": "IntegInitVpcPublicSubnet2Subnet9A384F16" + }, + "tags": [ + { + "key": "Name", + "value": "integ-init/IntegInitVpc/PublicSubnet2" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnNatGateway", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.PublicSubnet", + "version": "0.0.0" + } + }, + "PrivateSubnet1": { + "id": "PrivateSubnet1", + "path": "integ-init/IntegInitVpc/PrivateSubnet1", + "children": { + "Subnet": { + "id": "Subnet", + "path": "integ-init/IntegInitVpc/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": "integ-init/IntegInitVpc/PrivateSubnet1" + } + ], + "vpcId": { + "Ref": "IntegInitVpc0D4FCCB3" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "integ-init/IntegInitVpc/PrivateSubnet1/Acl", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "integ-init/IntegInitVpc/PrivateSubnet1/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "integ-init/IntegInitVpc/PrivateSubnet1" + } + ], + "vpcId": { + "Ref": "IntegInitVpc0D4FCCB3" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "integ-init/IntegInitVpc/PrivateSubnet1/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "IntegInitVpcPrivateSubnet1RouteTableCB37994B" + }, + "subnetId": { + "Ref": "IntegInitVpcPrivateSubnet1Subnet259B51C1" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnetRouteTableAssociation", + "version": "0.0.0" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "integ-init/IntegInitVpc/PrivateSubnet1/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "destinationCidrBlock": "0.0.0.0/0", + "natGatewayId": { + "Ref": "IntegInitVpcPublicSubnet1NATGateway46F32F7F" + }, + "routeTableId": { + "Ref": "IntegInitVpcPrivateSubnet1RouteTableCB37994B" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.PrivateSubnet", + "version": "0.0.0" + } + }, + "PrivateSubnet2": { + "id": "PrivateSubnet2", + "path": "integ-init/IntegInitVpc/PrivateSubnet2", + "children": { + "Subnet": { + "id": "Subnet", + "path": "integ-init/IntegInitVpc/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": "integ-init/IntegInitVpc/PrivateSubnet2" + } + ], + "vpcId": { + "Ref": "IntegInitVpc0D4FCCB3" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnet", + "version": "0.0.0" + } + }, + "Acl": { + "id": "Acl", + "path": "integ-init/IntegInitVpc/PrivateSubnet2/Acl", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "RouteTable": { + "id": "RouteTable", + "path": "integ-init/IntegInitVpc/PrivateSubnet2/RouteTable", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::RouteTable", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "integ-init/IntegInitVpc/PrivateSubnet2" + } + ], + "vpcId": { + "Ref": "IntegInitVpc0D4FCCB3" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRouteTable", + "version": "0.0.0" + } + }, + "RouteTableAssociation": { + "id": "RouteTableAssociation", + "path": "integ-init/IntegInitVpc/PrivateSubnet2/RouteTableAssociation", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SubnetRouteTableAssociation", + "aws:cdk:cloudformation:props": { + "routeTableId": { + "Ref": "IntegInitVpcPrivateSubnet2RouteTable030EC93B" + }, + "subnetId": { + "Ref": "IntegInitVpcPrivateSubnet2Subnet1643B059" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSubnetRouteTableAssociation", + "version": "0.0.0" + } + }, + "DefaultRoute": { + "id": "DefaultRoute", + "path": "integ-init/IntegInitVpc/PrivateSubnet2/DefaultRoute", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Route", + "aws:cdk:cloudformation:props": { + "destinationCidrBlock": "0.0.0.0/0", + "natGatewayId": { + "Ref": "IntegInitVpcPublicSubnet2NATGateway9CCB4A9C" + }, + "routeTableId": { + "Ref": "IntegInitVpcPrivateSubnet2RouteTable030EC93B" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnRoute", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.PrivateSubnet", + "version": "0.0.0" + } + }, + "IGW": { + "id": "IGW", + "path": "integ-init/IntegInitVpc/IGW", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::InternetGateway", + "aws:cdk:cloudformation:props": { + "tags": [ + { + "key": "Name", + "value": "integ-init/IntegInitVpc" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnInternetGateway", + "version": "0.0.0" + } + }, + "VPCGW": { + "id": "VPCGW", + "path": "integ-init/IntegInitVpc/VPCGW", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::VPCGatewayAttachment", + "aws:cdk:cloudformation:props": { + "internetGatewayId": { + "Ref": "IntegInitVpcIGWF019AC85" + }, + "vpcId": { + "Ref": "IntegInitVpc0D4FCCB3" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnVPCGatewayAttachment", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.Vpc", + "version": "0.0.0" + } + }, + "Instance2": { + "id": "Instance2", + "path": "integ-init/Instance2", + "children": { + "InstanceSecurityGroup": { + "id": "InstanceSecurityGroup", + "path": "integ-init/Instance2/InstanceSecurityGroup", + "children": { + "Resource": { + "id": "Resource", + "path": "integ-init/Instance2/InstanceSecurityGroup/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::SecurityGroup", + "aws:cdk:cloudformation:props": { + "groupDescription": "integ-init/Instance2/InstanceSecurityGroup", + "securityGroupEgress": [ + { + "cidrIp": "0.0.0.0/0", + "description": "Allow all outbound traffic by default", + "ipProtocol": "-1" + } + ], + "tags": [ + { + "key": "Name", + "value": "integ-init/Instance2" + } + ], + "vpcId": { + "Ref": "IntegInitVpc0D4FCCB3" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnSecurityGroup", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.SecurityGroup", + "version": "0.0.0" + } + }, + "InstanceRole": { + "id": "InstanceRole", + "path": "integ-init/Instance2/InstanceRole", + "children": { + "ImportInstanceRole": { + "id": "ImportInstanceRole", + "path": "integ-init/Instance2/InstanceRole/ImportInstanceRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "integ-init/Instance2/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": "integ-init/Instance2" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnRole", + "version": "0.0.0" + } + }, + "DefaultPolicy": { + "id": "DefaultPolicy", + "path": "integ-init/Instance2/InstanceRole/DefaultPolicy", + "children": { + "Resource": { + "id": "Resource", + "path": "integ-init/Instance2/InstanceRole/DefaultPolicy/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Policy", + "aws:cdk:cloudformation:props": { + "policyDocument": { + "Statement": [ + { + "Action": [ + "s3:GetBucket*", + "s3:GetObject*", + "s3:List*" + ], + "Effect": "Allow", + "Resource": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":s3:::", + { + "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" + }, + "/*" + ] + ] + }, + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":s3:::", + { + "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" + } + ] + ] + } + ] + }, + { + "Action": [ + "cloudformation:DescribeStackResource", + "cloudformation:SignalResource" + ], + "Effect": "Allow", + "Resource": { + "Ref": "AWS::StackId" + } + } + ], + "Version": "2012-10-17" + }, + "policyName": "Instance2InstanceRoleDefaultPolicy610B37CD", + "roles": [ + { + "Ref": "Instance2InstanceRole03DD7CB2" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnPolicy", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Policy", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0" + } + }, + "InstanceProfile": { + "id": "InstanceProfile", + "path": "integ-init/Instance2/InstanceProfile", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::InstanceProfile", + "aws:cdk:cloudformation:props": { + "roles": [ + { + "Ref": "Instance2InstanceRole03DD7CB2" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnInstanceProfile", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "integ-init/Instance2/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::EC2::Instance", + "aws:cdk:cloudformation:props": { + "availabilityZone": { + "Fn::Select": [ + 0, + { + "Fn::GetAZs": "" + } + ] + }, + "iamInstanceProfile": { + "Ref": "Instance2InstanceProfile582F915C" + }, + "imageId": { + "Ref": "SsmParameterValueawsserviceamiamazonlinuxlatestamznamihvmx8664gp2C96584B6F00A464EAD1953AFF4B05118Parameter" + }, + "instanceType": "t2.micro", + "securityGroupIds": [ + { + "Fn::GetAtt": [ + "Instance2InstanceSecurityGroupC6129B1D", + "GroupId" + ] + } + ], + "subnetId": { + "Ref": "IntegInitVpcPublicSubnet1Subnet41A6F6D4" + }, + "tags": [ + { + "key": "Name", + "value": "integ-init/Instance2" + } + ], + "userData": { + "Fn::Base64": { + "Fn::Join": [ + "", + [ + "#!/bin/bash\n# fingerprint: 4f2827c68bde31b4\n(\n set +e\n /opt/aws/bin/cfn-init -v --region ", + { + "Ref": "AWS::Region" + }, + " --stack ", + { + "Ref": "AWS::StackName" + }, + " --resource Instance255F3526574cbd507dfce8b71 -c default\n /opt/aws/bin/cfn-signal -e $? --region ", + { + "Ref": "AWS::Region" + }, + " --stack ", + { + "Ref": "AWS::StackName" + }, + " --resource Instance255F3526574cbd507dfce8b71\n cat /var/log/cfn-init.log >&2\n)" + ] + ] + } + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.CfnInstance", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_ec2.Instance", + "version": "0.0.0" + } + }, + "SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn-ami-hvm-x86_64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118.Parameter": { + "id": "SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn-ami-hvm-x86_64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118.Parameter", + "path": "integ-init/SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn-ami-hvm-x86_64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118.Parameter", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn-ami-hvm-x86_64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118": { + "id": "SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn-ami-hvm-x86_64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118", + "path": "integ-init/SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn-ami-hvm-x86_64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "8eb8c649578016a67a91b76e17aad728--tmp--sourceDirAsset": { + "id": "8eb8c649578016a67a91b76e17aad728--tmp--sourceDirAsset", + "path": "integ-init/8eb8c649578016a67a91b76e17aad728--tmp--sourceDirAsset", + "children": { + "Stage": { + "id": "Stage", + "path": "integ-init/8eb8c649578016a67a91b76e17aad728--tmp--sourceDirAsset/Stage", + "constructInfo": { + "fqn": "aws-cdk-lib.AssetStaging", + "version": "0.0.0" + } + }, + "AssetBucket": { + "id": "AssetBucket", + "path": "integ-init/8eb8c649578016a67a91b76e17aad728--tmp--sourceDirAsset/AssetBucket", + "constructInfo": { + "fqn": "aws-cdk-lib.aws_s3.BucketBase", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_s3_assets.Asset", + "version": "0.0.0" + } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "integ-init/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "integ-init/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + }, + "EnableSumTimeoutInstanceTest": { + "id": "EnableSumTimeoutInstanceTest", + "path": "EnableSumTimeoutInstanceTest", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "EnableSumTimeoutInstanceTest/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "EnableSumTimeoutInstanceTest/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "EnableSumTimeoutInstanceTest/DefaultTest/DeployAssert", + "children": { + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "EnableSumTimeoutInstanceTest/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "EnableSumTimeoutInstanceTest/DefaultTest/DeployAssert/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTestCase", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTest", + "version": "0.0.0" + } + }, + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.App", + "version": "0.0.0" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.ts new file mode 100644 index 0000000000000..b65d883c49672 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.enable-sum-timeout-instance-init.ts @@ -0,0 +1,76 @@ +#!/usr/bin/env node +import * as fs from 'fs'; +import * as path from 'path'; +import * as cdk from 'aws-cdk-lib'; +import * as ec2 from 'aws-cdk-lib/aws-ec2'; +import * as integ from '@aws-cdk/integ-tests-alpha'; +import { EC2_RESTRICT_DEFAULT_SECURITY_GROUP } from 'aws-cdk-lib/cx-api'; + +const app = new cdk.App({ + postCliContext: { + '@aws-cdk/aws-ec2:ec2SumTImeoutEnabled': true, + }, +}); +const stack = new cdk.Stack(app, 'integ-init'); +stack.node.setContext(EC2_RESTRICT_DEFAULT_SECURITY_GROUP, false); + +const vpc = new ec2.Vpc(stack, 'IntegInitVpc'); + +const tmpDir = fs.mkdtempSync('/tmp/cfn-enable-timeout-init-test'); +fs.writeFileSync(path.resolve(tmpDir, 'testFile'), 'Hello World!\n'); + +new ec2.Instance(stack, 'Instance2', { + vpc, + vpcSubnets: { subnetType: ec2.SubnetType.PUBLIC }, + instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE2, ec2.InstanceSize.MICRO), + machineImage: new ec2.AmazonLinuxImage(), + userDataCausesReplacement: true, + initOptions: { + timeout: cdk.Duration.minutes(30), + }, + init: ec2.CloudFormationInit.fromConfigSets({ + configSets: { + default: ['yumPreinstall', 'config'], + }, + configs: { + yumPreinstall: new ec2.InitConfig([ + ec2.InitPackage.yum('git'), + ]), + config: new ec2.InitConfig([ + ec2.InitFile.fromObject('/tmp/file2.json', { + stackId: stack.stackId, + stackName: stack.stackName, + region: stack.region, + intProperty: 18, + boolProperty: true, + numProperty: 58.23, + }), + ec2.InitGroup.fromName('group1'), + ec2.InitGroup.fromName('group2', 42), + ec2.InitUser.fromName('sysuser1', { + groups: ['group1', 'group2'], + homeDir: '/home/sysuser1-custom', + }), + ec2.InitUser.fromName('sysuser2'), + ec2.InitSource.fromAsset('/tmp/sourceDir', tmpDir), + ]), + service: new ec2.InitConfig([ + ec2.InitFile.fromString('/myvars.env', 'OTHER_VAR="im from the file :3"'), + ec2.InitService.systemdConfigFile('myapp', { + command: '/bin/bash -c "echo HELLO_WORLD=${MY_VAR} | FROM_FILE=${OTHER_VAR}"', + environmentVariables: { + MY_VAR: 'its me :)', + }, + environmentFiles: ['/myvars.env'], + }), + ]), + }, + }), + resourceSignalTimeout: cdk.Duration.minutes(10), +}); + +new integ.IntegTest(app, 'EnableSumTimeoutInstanceTest', { + testCases: [stack], +}); + +app.synth(); diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.instance-init.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.instance-init.js.snapshot/cdk.out index 1f0068d32659a..4efaa16f29af9 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.instance-init.js.snapshot/cdk.out +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.instance-init.js.snapshot/cdk.out @@ -1 +1 @@ -{"version":"36.0.0"} \ No newline at end of file +{"version":"36.0.24"} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.instance-init.js.snapshot/instanceinittestDefaultTestDeployAssert2123E149.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.instance-init.js.snapshot/instanceinittestDefaultTestDeployAssert2123E149.assets.json new file mode 100644 index 0000000000000..db96f4a75ee51 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.instance-init.js.snapshot/instanceinittestDefaultTestDeployAssert2123E149.assets.json @@ -0,0 +1,19 @@ +{ + "version": "36.0.24", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "instanceinittestDefaultTestDeployAssert2123E149.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/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.instance-init.js.snapshot/instanceinittestDefaultTestDeployAssert2123E149.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.instance-init.js.snapshot/instanceinittestDefaultTestDeployAssert2123E149.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.instance-init.js.snapshot/instanceinittestDefaultTestDeployAssert2123E149.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/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.instance-init.js.snapshot/integ-init.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.instance-init.js.snapshot/integ-init.assets.json index c53efbaabdb00..988022a5d17bd 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.instance-init.js.snapshot/integ-init.assets.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.instance-init.js.snapshot/integ-init.assets.json @@ -1,5 +1,5 @@ { - "version": "36.0.0", + "version": "36.0.24", "files": { "f8a1af398dac2fad92eeea4fb7620be1c4f504e23e3bfcd859fbb5744187930b": { "source": { @@ -14,7 +14,7 @@ } } }, - "9c8784d47f15e42c89ef49a12c54d18ab7a30bd3d43df229bf8b235d9928374a": { + "b192b3d7f396bf6d48c66382b79524cd57d9eef375b04b3b6391f3b8bf0d0d83": { "source": { "path": "integ-init.template.json", "packaging": "file" @@ -22,7 +22,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "9c8784d47f15e42c89ef49a12c54d18ab7a30bd3d43df229bf8b235d9928374a.json", + "objectKey": "b192b3d7f396bf6d48c66382b79524cd57d9eef375b04b3b6391f3b8bf0d0d83.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.instance-init.js.snapshot/integ-init.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.instance-init.js.snapshot/integ-init.template.json index 61a83874ac2c8..db1ea8fd9bbf3 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.instance-init.js.snapshot/integ-init.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.instance-init.js.snapshot/integ-init.template.json @@ -582,7 +582,7 @@ "CreationPolicy": { "ResourceSignal": { "Count": 1, - "Timeout": "PT30M" + "Timeout": "PT10M" } }, "Metadata": { diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.instance-init.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.instance-init.js.snapshot/integ.json index e6ea8f3290924..10e2b39bd3e1c 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.instance-init.js.snapshot/integ.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.instance-init.js.snapshot/integ.json @@ -1,14 +1,12 @@ { - "version": "36.0.0", + "version": "36.0.24", "testCases": { - "integ.instance-init": { + "instance-init-test/DefaultTest": { "stacks": [ "integ-init" ], - "diffAssets": false, - "stackUpdateWorkflow": true + "assertionStack": "instance-init-test/DefaultTest/DeployAssert", + "assertionStackName": "instanceinittestDefaultTestDeployAssert2123E149" } - }, - "synthContext": {}, - "enableLookups": false + } } \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.instance-init.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.instance-init.js.snapshot/manifest.json index e49e7eba966a3..2e8823fa53ca7 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.instance-init.js.snapshot/manifest.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.instance-init.js.snapshot/manifest.json @@ -1,5 +1,5 @@ { - "version": "36.0.0", + "version": "36.0.24", "artifacts": { "integ-init.assets": { "type": "cdk:asset-manifest", @@ -18,7 +18,7 @@ "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}/9c8784d47f15e42c89ef49a12c54d18ab7a30bd3d43df229bf8b235d9928374a.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/b192b3d7f396bf6d48c66382b79524cd57d9eef375b04b3b6391f3b8bf0d0d83.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ @@ -199,10 +199,7 @@ "/integ-init/Instance2/Resource": [ { "type": "aws:cdk:logicalId", - "data": "Instance255F3526574cbd507dfce8b71", - "trace": [ - "!!DESTRUCTIVE_CHANGES: WILL_DESTROY" - ] + "data": "Instance255F3526574cbd507dfce8b71" } ], "/integ-init/SsmParameterValue:--aws--service--ami-amazon-linux-latest--amzn-ami-hvm-x86_64-gp2:C96584B6-F00A-464E-AD19-53AFF4B05118.Parameter": [ @@ -226,6 +223,54 @@ }, "displayName": "integ-init" }, + "instanceinittestDefaultTestDeployAssert2123E149.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "instanceinittestDefaultTestDeployAssert2123E149.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "instanceinittestDefaultTestDeployAssert2123E149": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "instanceinittestDefaultTestDeployAssert2123E149.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": [ + "instanceinittestDefaultTestDeployAssert2123E149.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": [ + "instanceinittestDefaultTestDeployAssert2123E149.assets" + ], + "metadata": { + "/instance-init-test/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/instance-init-test/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "instance-init-test/DefaultTest/DeployAssert" + }, "Tree": { "type": "cdk:tree", "properties": { diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.instance-init.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.instance-init.js.snapshot/tree.json index 49b19533e3106..0b9ac3076ff67 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.instance-init.js.snapshot/tree.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.instance-init.js.snapshot/tree.json @@ -988,6 +988,60 @@ "version": "0.0.0" } }, + "instance-init-test": { + "id": "instance-init-test", + "path": "instance-init-test", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "instance-init-test/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "instance-init-test/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "instance-init-test/DefaultTest/DeployAssert", + "children": { + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "instance-init-test/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "instance-init-test/DefaultTest/DeployAssert/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTestCase", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTest", + "version": "0.0.0" + } + }, "Tree": { "id": "Tree", "path": "Tree", diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.instance-init.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.instance-init.ts index 15dfc02f434cf..b3dde02591055 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.instance-init.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-ec2/test/integ.instance-init.ts @@ -3,9 +3,14 @@ import * as fs from 'fs'; import * as path from 'path'; import * as cdk from 'aws-cdk-lib'; import * as ec2 from 'aws-cdk-lib/aws-ec2'; +import * as integ from '@aws-cdk/integ-tests-alpha'; import { EC2_RESTRICT_DEFAULT_SECURITY_GROUP } from 'aws-cdk-lib/cx-api'; -const app = new cdk.App(); +const app = new cdk.App({ + postCliContext: { + '@aws-cdk/aws-ec2:ec2SumTImeoutEnabled': false, + }, +}); const stack = new cdk.Stack(app, 'integ-init'); stack.node.setContext(EC2_RESTRICT_DEFAULT_SECURITY_GROUP, false); @@ -61,6 +66,11 @@ new ec2.Instance(stack, 'Instance2', { ]), }, }), + resourceSignalTimeout: cdk.Duration.minutes(10), +}); + +new integ.IntegTest(app, 'instance-init-test', { + testCases: [stack], }); app.synth(); diff --git a/packages/aws-cdk-lib/aws-ec2/lib/instance.ts b/packages/aws-cdk-lib/aws-ec2/lib/instance.ts index 8dbcbd58bd921..094a31e8995e8 100644 --- a/packages/aws-cdk-lib/aws-ec2/lib/instance.ts +++ b/packages/aws-cdk-lib/aws-ec2/lib/instance.ts @@ -15,8 +15,9 @@ import { UserData } from './user-data'; import { BlockDevice } from './volume'; import { IVpc, Subnet, SubnetSelection } from './vpc'; import * as iam from '../../aws-iam'; -import { Annotations, Aspects, Duration, Fn, IResource, Lazy, Resource, Stack, Tags, Token } from '../../core'; +import { Annotations, Aspects, Duration, FeatureFlags, Fn, IResource, Lazy, Resource, Stack, Tags, Token } from '../../core'; import { md5hash } from '../../core/lib/helpers-internal'; +import * as cxapi from '../../cx-api'; /** * Name tag constant @@ -589,11 +590,22 @@ export class Instance extends Resource implements IInstance { this.instancePublicDnsName = this.instance.attrPublicDnsName; this.instancePublicIp = this.instance.attrPublicIp; - if (props.init) { - this.applyCloudFormationInit(props.init, props.initOptions); - } + // When feature flag is true, if both the resourceSignalTimeout and initOptions.timeout are set, + // the timeout is summed together. This logic is done in applyCloudFormationInit. + // This is because applyUpdatePolicies overwrites the timeout when both timeout fields are specified. + if (FeatureFlags.of(this).isEnabled(cxapi.EC2_SUM_TIMEOUT_ENABLED)) { + this.applyUpdatePolicies(props); + + if (props.init) { + this.applyCloudFormationInit(props.init, props.initOptions); + } + } else { + if (props.init) { + this.applyCloudFormationInit(props.init, props.initOptions); + } - this.applyUpdatePolicies(props); + this.applyUpdatePolicies(props); + } // Trigger replacement (via new logical ID) on user data change, if specified or cfn-init is being used. // @@ -702,6 +714,7 @@ export class Instance extends Resource implements IInstance { this.instance.cfnOptions.creationPolicy = { ...this.instance.cfnOptions.creationPolicy, resourceSignal: { + ...this.instance.cfnOptions.creationPolicy?.resourceSignal, timeout: props.resourceSignalTimeout && props.resourceSignalTimeout.toIsoString(), }, }; diff --git a/packages/aws-cdk-lib/aws-ec2/test/instance.test.ts b/packages/aws-cdk-lib/aws-ec2/test/instance.test.ts index 54b25d09c2d6e..bddb94a4b3c90 100644 --- a/packages/aws-cdk-lib/aws-ec2/test/instance.test.ts +++ b/packages/aws-cdk-lib/aws-ec2/test/instance.test.ts @@ -3,7 +3,7 @@ import { Annotations, Match, Template } from '../../assertions'; import { Key } from '../../aws-kms'; import { Asset } from '../../aws-s3-assets'; import { StringParameter } from '../../aws-ssm'; -import { App, Stack } from '../../core'; +import { App, Stack, Duration } from '../../core'; import * as cxapi from '../../cx-api'; import { AmazonLinuxImage, @@ -1065,3 +1065,158 @@ test.each([true, false])('throw error for specifying ipv6AddressCount with assoc }); }).toThrow('You can\'t set both \'ipv6AddressCount\' and \'associatePublicIpAddress\''); }); + +test('resourceSignalTimeout overwrites initOptions.timeout when feature flag turned off', () => { + // GIVEN + const app = new App({ + context: { + [cxapi.EC2_SUM_TIMEOUT_ENABLED]: false, + }, + }); + stack = new Stack(app); + vpc = new Vpc(stack, 'Vpc)'); + new Instance(stack, 'Instance', { + vpc, + machineImage: new AmazonLinuxImage(), + instanceType: InstanceType.of(InstanceClass.T3, InstanceSize.LARGE), + init: CloudFormationInit.fromElements( + InitCommand.shellCommand('echo hello'), + ), + initOptions: { + timeout: Duration.minutes(30), + }, + resourceSignalTimeout: Duration.minutes(10), + }); + + // THEN + Template.fromStack(stack).hasResource('AWS::EC2::Instance', { + CreationPolicy: { + ResourceSignal: { + Count: 1, + Timeout: 'PT10M', + }, + }, + }); +}); + +test('initOptions.timeout and resourceSignalTimeout are both not set. Timeout is set to default of 5 min', () => { + // GIVEN + const app = new App({ + context: { + [cxapi.EC2_SUM_TIMEOUT_ENABLED]: true, + }, + }); + stack = new Stack(app); + vpc = new Vpc(stack, 'Vpc)'); + new Instance(stack, 'Instance', { + vpc, + machineImage: new AmazonLinuxImage(), + instanceType: InstanceType.of(InstanceClass.T3, InstanceSize.LARGE), + init: CloudFormationInit.fromElements( + InitCommand.shellCommand('echo hello'), + ), + }); + + // THEN + Template.fromStack(stack).hasResource('AWS::EC2::Instance', { + CreationPolicy: { + ResourceSignal: { + Timeout: 'PT5M', + }, + }, + }); +}); + +test('initOptions.timeout is set and not resourceSignalTimeout. Timeout is set to initOptions.timeout value', () => { + // GIVEN + const app = new App({ + context: { + [cxapi.EC2_SUM_TIMEOUT_ENABLED]: true, + }, + }); + stack = new Stack(app); + vpc = new Vpc(stack, 'Vpc)'); + new Instance(stack, 'Instance', { + vpc, + machineImage: new AmazonLinuxImage(), + instanceType: InstanceType.of(InstanceClass.T3, InstanceSize.LARGE), + init: CloudFormationInit.fromElements( + InitCommand.shellCommand('echo hello'), + ), + initOptions: { + timeout: Duration.minutes(10), + }, + }); + + // THEN + Template.fromStack(stack).hasResource('AWS::EC2::Instance', { + CreationPolicy: { + ResourceSignal: { + Count: 1, + Timeout: 'PT10M', + }, + }, + }); +}); + +test('resourceSignalTimeout is set and not initOptions.timeout. Timeout is set to resourceSignalTimeout value', () => { + // GIVEN + const app = new App({ + context: { + [cxapi.EC2_SUM_TIMEOUT_ENABLED]: true, + }, + }); + stack = new Stack(app); + vpc = new Vpc(stack, 'Vpc)'); + new Instance(stack, 'Instance', { + vpc, + machineImage: new AmazonLinuxImage(), + instanceType: InstanceType.of(InstanceClass.T3, InstanceSize.LARGE), + init: CloudFormationInit.fromElements( + InitCommand.shellCommand('echo hello'), + ), + resourceSignalTimeout: Duration.minutes(10), + }); + + // THEN + Template.fromStack(stack).hasResource('AWS::EC2::Instance', { + CreationPolicy: { + ResourceSignal: { + Timeout: 'PT15M', + }, + }, + }); +}); + +test('resourceSignalTimeout and initOptions.timeout are both set, sum timeout and log warning', () => { + // GIVEN + const app = new App({ + context: { + [cxapi.EC2_SUM_TIMEOUT_ENABLED]: true, + }, + }); + stack = new Stack(app); + vpc = new Vpc(stack, 'Vpc)'); + new Instance(stack, 'Instance', { + vpc, + machineImage: new AmazonLinuxImage(), + instanceType: InstanceType.of(InstanceClass.T3, InstanceSize.LARGE), + init: CloudFormationInit.fromElements( + InitCommand.shellCommand('echo hello'), + ), + initOptions: { + timeout: Duration.minutes(10), + }, + resourceSignalTimeout: Duration.minutes(10), + }); + + // THEN + Template.fromStack(stack).hasResource('AWS::EC2::Instance', { + CreationPolicy: { + ResourceSignal: { + Count: 1, + Timeout: 'PT20M', + }, + }, + }); +}); \ No newline at end of file diff --git a/packages/aws-cdk-lib/cx-api/FEATURE_FLAGS.md b/packages/aws-cdk-lib/cx-api/FEATURE_FLAGS.md index beadd60aa4ed2..996ccc96e72dd 100644 --- a/packages/aws-cdk-lib/cx-api/FEATURE_FLAGS.md +++ b/packages/aws-cdk-lib/cx-api/FEATURE_FLAGS.md @@ -74,6 +74,7 @@ Flags come in three types: | [@aws-cdk/aws-s3:keepNotificationInImportedBucket](#aws-cdkaws-s3keepnotificationinimportedbucket) | When enabled, Adding notifications to a bucket in the current stack will not remove notification from imported stack. | 2.155.0 | (fix) | | [@aws-cdk/aws-stepfunctions-tasks:useNewS3UriParametersForBedrockInvokeModelTask](#aws-cdkaws-stepfunctions-tasksusenews3uriparametersforbedrockinvokemodeltask) | When enabled, use new props for S3 URI field in task definition of state machine for bedrock invoke model. | 2.156.0 | (fix) | | [@aws-cdk/aws-ecs:reduceEc2FargateCloudWatchPermissions](#aws-cdkaws-ecsreduceec2fargatecloudwatchpermissions) | When enabled, we will only grant the necessary permissions when users specify cloudwatch log group through logConfiguration | 2.159.0 | (fix) | +| [@aws-cdk/aws-ec2:ec2SumTImeoutEnabled](#aws-cdkaws-ec2ec2sumtimeoutenabled) | When enabled, initOptions.timeout and resourceSignalTimeout values will be summed together. | V2NEXT | (fix) | @@ -136,7 +137,8 @@ The following json shows the current recommended set of flags, as `cdk init` wou "@aws-cdk/aws-ecs:removeDefaultDeploymentAlarm": true, "@aws-cdk/custom-resources:logApiResponseDataPropertyTrueDefault": false, "@aws-cdk/aws-s3:keepNotificationInImportedBucket": false, - "@aws-cdk/aws-ecs:reduceEc2FargateCloudWatchPermissions": true + "@aws-cdk/aws-ecs:reduceEc2FargateCloudWatchPermissions": true, + "@aws-cdk/aws-ec2:ec2SumTImeoutEnabled": true } } ``` @@ -1398,4 +1400,20 @@ When this feature flag is enabled, we will only grant the necessary permissions **Compatibility with old behavior:** Disable the feature flag to continue grant permissions to log group when no log group is specified +### @aws-cdk/aws-ec2:ec2SumTImeoutEnabled + +*When enabled, initOptions.timeout and resourceSignalTimeout values will be summed together.* (fix) + +Currently is both initOptions.timeout and resourceSignalTimeout are both specified in the options for creating an EC2 Instance, +only the value from 'resourceSignalTimeout' will be used. + +When this feature flag is enabled, if both initOptions.timeout and resourceSignalTimeout are specified, the values will to be summed together. + + +| Since | Default | Recommended | +| ----- | ----- | ----- | +| (not in v1) | | | +| V2NEXT | `false` | `true` | + + diff --git a/packages/aws-cdk-lib/cx-api/README.md b/packages/aws-cdk-lib/cx-api/README.md index 946c8ae6224c5..9e0888c7c28ff 100644 --- a/packages/aws-cdk-lib/cx-api/README.md +++ b/packages/aws-cdk-lib/cx-api/README.md @@ -409,3 +409,19 @@ _cdk.json_ } } ``` + +* `@aws-cdk/aws-ec2:ec2SumTImeoutEnabled` + +Currently is both initOptions.timeout and resourceSignalTimeout are both specified in the options for creating an EC2 Instance, only the value from 'resourceSignalTimeout' will be used. + +When this feature flag is enabled, if both initOptions.timeout and resourceSignalTimeout are specified, the values will to be summed together. + +_cdk.json_ + +```json +{ + "context": { + "@aws-cdk/aws-ec2:ec2SumTImeoutEnabled": true + } +} +``` \ No newline at end of file diff --git a/packages/aws-cdk-lib/cx-api/lib/features.ts b/packages/aws-cdk-lib/cx-api/lib/features.ts index e1035fd94fee2..48d109404ca4c 100644 --- a/packages/aws-cdk-lib/cx-api/lib/features.ts +++ b/packages/aws-cdk-lib/cx-api/lib/features.ts @@ -108,6 +108,7 @@ export const LOG_API_RESPONSE_DATA_PROPERTY_TRUE_DEFAULT = '@aws-cdk/custom-reso export const S3_KEEP_NOTIFICATION_IN_IMPORTED_BUCKET = '@aws-cdk/aws-s3:keepNotificationInImportedBucket'; export const USE_NEW_S3URI_PARAMETERS_FOR_BEDROCK_INVOKE_MODEL_TASK = '@aws-cdk/aws-stepfunctions-tasks:useNewS3UriParametersForBedrockInvokeModelTask'; export const REDUCE_EC2_FARGATE_CLOUDWATCH_PERMISSIONS = '@aws-cdk/aws-ecs:reduceEc2FargateCloudWatchPermissions'; +export const EC2_SUM_TIMEOUT_ENABLED = '@aws-cdk/aws-ec2:ec2SumTImeoutEnabled'; export const FLAGS: Record = { ////////////////////////////////////////////////////////////////////// @@ -1142,6 +1143,20 @@ export const FLAGS: Record = { recommendedValue: true, compatibilityWithOldBehaviorMd: 'Disable the feature flag to continue grant permissions to log group when no log group is specified', }, + + ////////////////////////////////////////////////////////////////////// + [EC2_SUM_TIMEOUT_ENABLED]: { + type: FlagType.BugFix, + summary: 'When enabled, initOptions.timeout and resourceSignalTimeout values will be summed together.', + detailsMd: ` + Currently is both initOptions.timeout and resourceSignalTimeout are both specified in the options for creating an EC2 Instance, + only the value from 'resourceSignalTimeout' will be used. + + When this feature flag is enabled, if both initOptions.timeout and resourceSignalTimeout are specified, the values will to be summed together. + `, + recommendedValue: true, + introducedIn: { v2: 'V2NEXT' }, + }, }; const CURRENT_MV = 'v2';