From bacccb38cdf2b5784f53e0f289133404f4ae6fd8 Mon Sep 17 00:00:00 2001 From: Hogan Bobertz Date: Fri, 15 Sep 2023 13:13:50 -0400 Subject: [PATCH 01/39] chore: empty test for future canary --- .../tests/migrate/migrate.integtest.ts | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 packages/@aws-cdk-testing/cli-integ/tests/migrate/migrate.integtest.ts diff --git a/packages/@aws-cdk-testing/cli-integ/tests/migrate/migrate.integtest.ts b/packages/@aws-cdk-testing/cli-integ/tests/migrate/migrate.integtest.ts new file mode 100644 index 0000000000000..e3324c4836e50 --- /dev/null +++ b/packages/@aws-cdk-testing/cli-integ/tests/migrate/migrate.integtest.ts @@ -0,0 +1,29 @@ +import { + integTest, + withTemporaryDirectory, + withPackages, +} from '../../lib'; + +integTest( + 'cdk migrate typescript', + withTemporaryDirectory( + withPackages(async () => { + // const shell = ShellHelper.fromContext(context); + // await context.packages.makeCliAvailable(); + + // const tempPath = path.resolve(context.integTestDir); + // const inputFile = path.join(__dirname, 'template.yml'); + + // await shell.shell([ + // 'cdk', + // 'migrate', + // '-l', + // 'typescript', + // '--from-path', + // inputFile, + // '--output-path', + // tempPath, + // ]); + }), + ), +); From 98092172eba49e042a488701cd5f176a0b07fab6 Mon Sep 17 00:00:00 2001 From: Hogan Bobertz Date: Fri, 15 Sep 2023 13:15:46 -0400 Subject: [PATCH 02/39] dummify test even more --- .../tests/migrate/migrate.integtest.ts | 29 ++----------------- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/packages/@aws-cdk-testing/cli-integ/tests/migrate/migrate.integtest.ts b/packages/@aws-cdk-testing/cli-integ/tests/migrate/migrate.integtest.ts index e3324c4836e50..925198576256f 100644 --- a/packages/@aws-cdk-testing/cli-integ/tests/migrate/migrate.integtest.ts +++ b/packages/@aws-cdk-testing/cli-integ/tests/migrate/migrate.integtest.ts @@ -1,29 +1,6 @@ -import { - integTest, - withTemporaryDirectory, - withPackages, -} from '../../lib'; +import { integTest, withTemporaryDirectory, withPackages } from "../../lib"; integTest( - 'cdk migrate typescript', - withTemporaryDirectory( - withPackages(async () => { - // const shell = ShellHelper.fromContext(context); - // await context.packages.makeCliAvailable(); - - // const tempPath = path.resolve(context.integTestDir); - // const inputFile = path.join(__dirname, 'template.yml'); - - // await shell.shell([ - // 'cdk', - // 'migrate', - // '-l', - // 'typescript', - // '--from-path', - // inputFile, - // '--output-path', - // tempPath, - // ]); - }), - ), + "cdk migrate typescript", + withTemporaryDirectory(withPackages(async () => {})) ); From deb71a1e49c883bc46b0a90210286049e1e587ee Mon Sep 17 00:00:00 2001 From: Hogan Bobertz Date: Fri, 15 Sep 2023 14:22:05 -0400 Subject: [PATCH 03/39] fix clippy being upset --- .../cli-integ/tests/migrate/migrate.integtest.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/@aws-cdk-testing/cli-integ/tests/migrate/migrate.integtest.ts b/packages/@aws-cdk-testing/cli-integ/tests/migrate/migrate.integtest.ts index 925198576256f..42117ac8b34ce 100644 --- a/packages/@aws-cdk-testing/cli-integ/tests/migrate/migrate.integtest.ts +++ b/packages/@aws-cdk-testing/cli-integ/tests/migrate/migrate.integtest.ts @@ -1,6 +1,10 @@ -import { integTest, withTemporaryDirectory, withPackages } from "../../lib"; +import { integTest, withTemporaryDirectory, withPackages } from '../../lib'; integTest( - "cdk migrate typescript", - withTemporaryDirectory(withPackages(async () => {})) + 'cdk migrate typescript', + withTemporaryDirectory( + withPackages(async () => { + // TODO: Add the test after pipeline expects it + }), + ), ); From 68e53a3375adc8f4b29edab7536555ddbc1c0d0a Mon Sep 17 00:00:00 2001 From: Hogan Bobertz Date: Mon, 18 Sep 2023 12:15:32 -0400 Subject: [PATCH 04/39] add migrate test into cli-integ-tets --- .../tests/cli-integ-tests/cli.integtest.ts | 27 +- .../tests/cli-integ-tests/template.txt | 414 ++++++++++++++++++ .../tests/migrate/migrate.integtest.ts | 10 - 3 files changed, 440 insertions(+), 11 deletions(-) create mode 100644 packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/template.txt delete mode 100644 packages/@aws-cdk-testing/cli-integ/tests/migrate/migrate.integtest.ts diff --git a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts index b5b55ba5a6a75..ac965944af314 100644 --- a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts +++ b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts @@ -1,7 +1,7 @@ import { promises as fs, existsSync } from 'fs'; import * as os from 'os'; import * as path from 'path'; -import { integTest, cloneDirectory, shell, withDefaultFixture, retry, sleep, randomInteger, withSamIntegrationFixture, RESOURCES_DIR } from '../../lib'; +import { integTest, cloneDirectory, shell, withDefaultFixture, retry, sleep, randomInteger, withSamIntegrationFixture, RESOURCES_DIR, withTemporaryDirectory, ShellHelper, withPackages } from '../../lib'; jest.setTimeout(2 * 60 * 60_000); // Includes the time to acquire locks, worst-case single-threaded runtime @@ -50,6 +50,31 @@ integTest('VPC Lookup', withDefaultFixture(async (fixture) => { await fixture.cdkDeploy('import-vpc', { modEnv: { ENABLE_VPC_TESTING: 'IMPORT' } }); })); +integTest( + 'cdk migrate typescript', + withTemporaryDirectory( + withPackages(async (context) => { + + const tempShell = ShellHelper.fromContext(context); + await context.packages.makeCliAvailable(); + + const tempPath = path.resolve(context.integTestDir); + const inputFile = path.join(__dirname, 'template.txt'); + + await tempShell.shell([ + 'cdk', + 'migrate', + '-l', + 'typescript', + '--from-path', + inputFile, + '--output-path', + tempPath, + ]); + }), + ), +); + // testing a construct with a builtin Nodejs Lambda Function. // In this case we are testing the s3.Bucket construct with the // autoDeleteObjects prop set to true, which creates a Lambda backed diff --git a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/template.txt b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/template.txt new file mode 100644 index 0000000000000..29b4ea3689351 --- /dev/null +++ b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/template.txt @@ -0,0 +1,414 @@ +{ + "AWSTemplateFormatVersion" : "2010-09-09", + + "Description" : "AWS CloudFormation Sample Template LAMP_Single_Instance: Create a LAMP stack using a single EC2 instance and a local MySQL database for storage. This template demonstrates using the AWS CloudFormation bootstrap scripts to install the packages and files necessary to deploy the Apache web server, PHP and MySQL at instance launch time. **WARNING** This template creates an Amazon EC2 instance. You will be billed for the AWS resources used if you create a stack from this template.", + + "Parameters" : { + + "KeyName": { + "Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instance", + "Type": "AWS::EC2::KeyPair::KeyName", + "ConstraintDescription" : "must be the name of an existing EC2 KeyPair." + }, + + "DBName": { + "Default": "MyDatabase", + "Description" : "MySQL database name", + "Type": "String", + "MinLength": "1", + "MaxLength": "64", + "AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*", + "ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters." + }, + + "DBUser": { + "NoEcho": "true", + "Description" : "Username for MySQL database access", + "Type": "String", + "MinLength": "1", + "MaxLength": "16", + "AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*", + "ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters." + }, + + "DBPassword": { + "NoEcho": "true", + "Description" : "Password for MySQL database access", + "Type": "String", + "MinLength": "1", + "MaxLength": "41", + "AllowedPattern" : "[a-zA-Z0-9]*", + "ConstraintDescription" : "must contain only alphanumeric characters." + }, + + "DBRootPassword": { + "NoEcho": "true", + "Description" : "Root password for MySQL", + "Type": "String", + "MinLength": "1", + "MaxLength": "41", + "AllowedPattern" : "[a-zA-Z0-9]*", + "ConstraintDescription" : "must contain only alphanumeric characters." + }, + + "InstanceType" : { + "Description" : "WebServer EC2 instance type", + "Type" : "String", + "Default" : "t2.small", + "AllowedValues" : [ "t1.micro", "t2.nano", "t2.micro", "t2.small", "t2.medium", "t2.large", "m1.small", "m1.medium", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "m3.medium", "m3.large", "m3.xlarge", "m3.2xlarge", "m4.large", "m4.xlarge", "m4.2xlarge", "m4.4xlarge", "m4.10xlarge", "c1.medium", "c1.xlarge", "c3.large", "c3.xlarge", "c3.2xlarge", "c3.4xlarge", "c3.8xlarge", "c4.large", "c4.xlarge", "c4.2xlarge", "c4.4xlarge", "c4.8xlarge", "g2.2xlarge", "g2.8xlarge", "r3.large", "r3.xlarge", "r3.2xlarge", "r3.4xlarge", "r3.8xlarge", "i2.xlarge", "i2.2xlarge", "i2.4xlarge", "i2.8xlarge", "d2.xlarge", "d2.2xlarge", "d2.4xlarge", "d2.8xlarge", "hi1.4xlarge", "hs1.8xlarge", "cr1.8xlarge", "cc2.8xlarge", "cg1.4xlarge"] +, + "ConstraintDescription" : "must be a valid EC2 instance type." + }, + + "SSHLocation" : { + "Description" : " The IP address range that can be used to SSH to the EC2 instances", + "Type": "String", + "MinLength": "9", + "MaxLength": "18", + "Default": "0.0.0.0/0", + "AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})", + "ConstraintDescription": "must be a valid IP CIDR range of the form x.x.x.x/x." + } + }, + + "Mappings" : { + "AWSInstanceType2Arch" : { + "t1.micro" : { "Arch" : "HVM64" }, + "t2.nano" : { "Arch" : "HVM64" }, + "t2.micro" : { "Arch" : "HVM64" }, + "t2.small" : { "Arch" : "HVM64" }, + "t2.medium" : { "Arch" : "HVM64" }, + "t2.large" : { "Arch" : "HVM64" }, + "m1.small" : { "Arch" : "HVM64" }, + "m1.medium" : { "Arch" : "HVM64" }, + "m1.large" : { "Arch" : "HVM64" }, + "m1.xlarge" : { "Arch" : "HVM64" }, + "m2.xlarge" : { "Arch" : "HVM64" }, + "m2.2xlarge" : { "Arch" : "HVM64" }, + "m2.4xlarge" : { "Arch" : "HVM64" }, + "m3.medium" : { "Arch" : "HVM64" }, + "m3.large" : { "Arch" : "HVM64" }, + "m3.xlarge" : { "Arch" : "HVM64" }, + "m3.2xlarge" : { "Arch" : "HVM64" }, + "m4.large" : { "Arch" : "HVM64" }, + "m4.xlarge" : { "Arch" : "HVM64" }, + "m4.2xlarge" : { "Arch" : "HVM64" }, + "m4.4xlarge" : { "Arch" : "HVM64" }, + "m4.10xlarge" : { "Arch" : "HVM64" }, + "c1.medium" : { "Arch" : "HVM64" }, + "c1.xlarge" : { "Arch" : "HVM64" }, + "c3.large" : { "Arch" : "HVM64" }, + "c3.xlarge" : { "Arch" : "HVM64" }, + "c3.2xlarge" : { "Arch" : "HVM64" }, + "c3.4xlarge" : { "Arch" : "HVM64" }, + "c3.8xlarge" : { "Arch" : "HVM64" }, + "c4.large" : { "Arch" : "HVM64" }, + "c4.xlarge" : { "Arch" : "HVM64" }, + "c4.2xlarge" : { "Arch" : "HVM64" }, + "c4.4xlarge" : { "Arch" : "HVM64" }, + "c4.8xlarge" : { "Arch" : "HVM64" }, + "g2.2xlarge" : { "Arch" : "HVMG2" }, + "g2.8xlarge" : { "Arch" : "HVMG2" }, + "r3.large" : { "Arch" : "HVM64" }, + "r3.xlarge" : { "Arch" : "HVM64" }, + "r3.2xlarge" : { "Arch" : "HVM64" }, + "r3.4xlarge" : { "Arch" : "HVM64" }, + "r3.8xlarge" : { "Arch" : "HVM64" }, + "i2.xlarge" : { "Arch" : "HVM64" }, + "i2.2xlarge" : { "Arch" : "HVM64" }, + "i2.4xlarge" : { "Arch" : "HVM64" }, + "i2.8xlarge" : { "Arch" : "HVM64" }, + "d2.xlarge" : { "Arch" : "HVM64" }, + "d2.2xlarge" : { "Arch" : "HVM64" }, + "d2.4xlarge" : { "Arch" : "HVM64" }, + "d2.8xlarge" : { "Arch" : "HVM64" }, + "hi1.4xlarge" : { "Arch" : "HVM64" }, + "hs1.8xlarge" : { "Arch" : "HVM64" }, + "cr1.8xlarge" : { "Arch" : "HVM64" }, + "cc2.8xlarge" : { "Arch" : "HVM64" } + }, + + "AWSInstanceType2NATArch" : { + "t1.micro" : { "Arch" : "NATHVM64" }, + "t2.nano" : { "Arch" : "NATHVM64" }, + "t2.micro" : { "Arch" : "NATHVM64" }, + "t2.small" : { "Arch" : "NATHVM64" }, + "t2.medium" : { "Arch" : "NATHVM64" }, + "t2.large" : { "Arch" : "NATHVM64" }, + "m1.small" : { "Arch" : "NATHVM64" }, + "m1.medium" : { "Arch" : "NATHVM64" }, + "m1.large" : { "Arch" : "NATHVM64" }, + "m1.xlarge" : { "Arch" : "NATHVM64" }, + "m2.xlarge" : { "Arch" : "NATHVM64" }, + "m2.2xlarge" : { "Arch" : "NATHVM64" }, + "m2.4xlarge" : { "Arch" : "NATHVM64" }, + "m3.medium" : { "Arch" : "NATHVM64" }, + "m3.large" : { "Arch" : "NATHVM64" }, + "m3.xlarge" : { "Arch" : "NATHVM64" }, + "m3.2xlarge" : { "Arch" : "NATHVM64" }, + "m4.large" : { "Arch" : "NATHVM64" }, + "m4.xlarge" : { "Arch" : "NATHVM64" }, + "m4.2xlarge" : { "Arch" : "NATHVM64" }, + "m4.4xlarge" : { "Arch" : "NATHVM64" }, + "m4.10xlarge" : { "Arch" : "NATHVM64" }, + "c1.medium" : { "Arch" : "NATHVM64" }, + "c1.xlarge" : { "Arch" : "NATHVM64" }, + "c3.large" : { "Arch" : "NATHVM64" }, + "c3.xlarge" : { "Arch" : "NATHVM64" }, + "c3.2xlarge" : { "Arch" : "NATHVM64" }, + "c3.4xlarge" : { "Arch" : "NATHVM64" }, + "c3.8xlarge" : { "Arch" : "NATHVM64" }, + "c4.large" : { "Arch" : "NATHVM64" }, + "c4.xlarge" : { "Arch" : "NATHVM64" }, + "c4.2xlarge" : { "Arch" : "NATHVM64" }, + "c4.4xlarge" : { "Arch" : "NATHVM64" }, + "c4.8xlarge" : { "Arch" : "NATHVM64" }, + "g2.2xlarge" : { "Arch" : "NATHVMG2" }, + "g2.8xlarge" : { "Arch" : "NATHVMG2" }, + "r3.large" : { "Arch" : "NATHVM64" }, + "r3.xlarge" : { "Arch" : "NATHVM64" }, + "r3.2xlarge" : { "Arch" : "NATHVM64" }, + "r3.4xlarge" : { "Arch" : "NATHVM64" }, + "r3.8xlarge" : { "Arch" : "NATHVM64" }, + "i2.xlarge" : { "Arch" : "NATHVM64" }, + "i2.2xlarge" : { "Arch" : "NATHVM64" }, + "i2.4xlarge" : { "Arch" : "NATHVM64" }, + "i2.8xlarge" : { "Arch" : "NATHVM64" }, + "d2.xlarge" : { "Arch" : "NATHVM64" }, + "d2.2xlarge" : { "Arch" : "NATHVM64" }, + "d2.4xlarge" : { "Arch" : "NATHVM64" }, + "d2.8xlarge" : { "Arch" : "NATHVM64" }, + "hi1.4xlarge" : { "Arch" : "NATHVM64" }, + "hs1.8xlarge" : { "Arch" : "NATHVM64" }, + "cr1.8xlarge" : { "Arch" : "NATHVM64" }, + "cc2.8xlarge" : { "Arch" : "NATHVM64" } + } +, + "AWSRegionArch2AMI" : { + "af-south-1" : {"HVM64" : "ami-064cc455f8a1ef504", "HVMG2" : "NOT_SUPPORTED"}, + "ap-east-1" : {"HVM64" : "ami-f85b1989", "HVMG2" : "NOT_SUPPORTED"}, + "ap-northeast-1" : {"HVM64" : "ami-0b2c2a754d5b4da22", "HVMG2" : "ami-09d0e0e099ecabba2"}, + "ap-northeast-2" : {"HVM64" : "ami-0493ab99920f410fc", "HVMG2" : "NOT_SUPPORTED"}, + "ap-northeast-3" : {"HVM64" : "ami-01344f6f63a4decc1", "HVMG2" : "NOT_SUPPORTED"}, + "ap-south-1" : {"HVM64" : "ami-03cfb5e1fb4fac428", "HVMG2" : "ami-0244c1d42815af84a"}, + "ap-southeast-1" : {"HVM64" : "ami-0ba35dc9caf73d1c7", "HVMG2" : "ami-0e46ce0d6a87dc979"}, + "ap-southeast-2" : {"HVM64" : "ami-0ae99b503e8694028", "HVMG2" : "ami-0c0ab057a101d8ff2"}, + "ca-central-1" : {"HVM64" : "ami-0803e21a2ec22f953", "HVMG2" : "NOT_SUPPORTED"}, + "cn-north-1" : {"HVM64" : "ami-07a3f215cc90c889c", "HVMG2" : "NOT_SUPPORTED"}, + "cn-northwest-1" : {"HVM64" : "ami-0a3b3b10f714a0ff4", "HVMG2" : "NOT_SUPPORTED"}, + "eu-central-1" : {"HVM64" : "ami-0474863011a7d1541", "HVMG2" : "ami-0aa1822e3eb913a11"}, + "eu-north-1" : {"HVM64" : "ami-0de4b8910494dba0f", "HVMG2" : "ami-32d55b4c"}, + "eu-south-1" : {"HVM64" : "ami-08427144fe9ebdef6", "HVMG2" : "NOT_SUPPORTED"}, + "eu-west-1" : {"HVM64" : "ami-015232c01a82b847b", "HVMG2" : "ami-0d5299b1c6112c3c7"}, + "eu-west-2" : {"HVM64" : "ami-0765d48d7e15beb93", "HVMG2" : "NOT_SUPPORTED"}, + "eu-west-3" : {"HVM64" : "ami-0caf07637eda19d9c", "HVMG2" : "NOT_SUPPORTED"}, + "me-south-1" : {"HVM64" : "ami-0744743d80915b497", "HVMG2" : "NOT_SUPPORTED"}, + "sa-east-1" : {"HVM64" : "ami-0a52e8a6018e92bb0", "HVMG2" : "NOT_SUPPORTED"}, + "us-east-1" : {"HVM64" : "ami-032930428bf1abbff", "HVMG2" : "ami-0aeb704d503081ea6"}, + "us-east-2" : {"HVM64" : "ami-027cab9a7bf0155df", "HVMG2" : "NOT_SUPPORTED"}, + "us-west-1" : {"HVM64" : "ami-088c153f74339f34c", "HVMG2" : "ami-0a7fc72dc0e51aa77"}, + "us-west-2" : {"HVM64" : "ami-01fee56b22f308154", "HVMG2" : "ami-0fe84a5b4563d8f27"} + } + + }, + + "Resources" : { + + "WebServerInstance": { + "Type": "AWS::EC2::Instance", + "Metadata" : { + "AWS::CloudFormation::Init" : { + "configSets" : { + "InstallAndRun" : [ "Install", "Configure" ] + }, + + "Install" : { + "packages" : { + "yum" : { + "mysql" : [], + "mysql-server" : [], + "mysql-libs" : [], + "httpd" : [], + "php" : [], + "php-mysql" : [] + } + }, + + "files" : { + "/var/www/html/index.php" : { + "content" : { "Fn::Join" : [ "", [ + "\n", + " \n", + " AWS CloudFormation PHP Sample\n", + " \n", + " \n", + " \n", + "

Welcome to the AWS CloudFormation PHP Sample

\n", + "

\n", + " \";\n", + " print date(\"g:i A l, F j Y.\");\n", + " ?>\n", + "

\n", + " \";\n", + " }\n", + " else\n", + " {\n", + " print \"Server = \" . $hostname . \"
\";\n", + " }\n", + " // Get the instance-id of the intance from the instance metadata\n", + " curl_setopt($curl_handle,CURLOPT_URL,'http://169.254.169.254/latest/meta-data/instance-id');\n", + " $instanceid = curl_exec($curl_handle);\n", + " if (empty($instanceid))\n", + " {\n", + " print \"Sorry, for some reason, we got no instance id back
\";\n", + " }\n", + " else\n", + " {\n", + " print \"EC2 instance-id = \" . $instanceid . \"
\";\n", + " }\n", + " $Database = \"localhost\";\n", + " $DBUser = \"", {"Ref" : "DBUser"}, "\";\n", + " $DBPassword = \"", {"Ref" : "DBPassword"}, "\";\n", + " print \"Database = \" . $Database . \"
\";\n", + " $dbconnection = mysql_connect($Database, $DBUser, $DBPassword)\n", + " or die(\"Could not connect: \" . mysql_error());\n", + " print (\"Connected to $Database successfully\");\n", + " mysql_close($dbconnection);\n", + " ?>\n", + "

PHP Information

\n", + "

\n", + " \n", + " \n", + "\n" + ]]}, + "mode" : "000600", + "owner" : "apache", + "group" : "apache" + }, + + "/tmp/setup.mysql" : { + "content" : { "Fn::Join" : ["", [ + "CREATE DATABASE ", { "Ref" : "DBName" }, ";\n", + "GRANT ALL ON ", { "Ref" : "DBName" }, ".* TO '", { "Ref" : "DBUser" }, "'@localhost IDENTIFIED BY '", { "Ref" : "DBPassword" }, "';\n" + ]]}, + "mode" : "000400", + "owner" : "root", + "group" : "root" + }, + "/etc/cfn/cfn-hup.conf" : { + "content" : { "Fn::Join" : ["", [ + "[main]\n", + "stack=", { "Ref" : "AWS::StackId" }, "\n", + "region=", { "Ref" : "AWS::Region" }, "\n" + ]]}, + "mode" : "000400", + "owner" : "root", + "group" : "root" + }, + + "/etc/cfn/hooks.d/cfn-auto-reloader.conf" : { + "content": { "Fn::Join" : ["", [ + "[cfn-auto-reloader-hook]\n", + "triggers=post.update\n", + "path=Resources.WebServerInstance.Metadata.AWS::CloudFormation::Init\n", + "action=/opt/aws/bin/cfn-init -v ", + " --stack ", { "Ref" : "AWS::StackName" }, + " --resource WebServerInstance ", + " --configsets InstallAndRun ", + " --region ", { "Ref" : "AWS::Region" }, "\n", + "runas=root\n" + ]]}, + "mode" : "000400", + "owner" : "root", + "group" : "root" + } + }, + + "services" : { + "sysvinit" : { + "mysqld" : { "enabled" : "true", "ensureRunning" : "true" }, + "httpd" : { "enabled" : "true", "ensureRunning" : "true" }, + "cfn-hup" : { "enabled" : "true", "ensureRunning" : "true", + "files" : ["/etc/cfn/cfn-hup.conf", "/etc/cfn/hooks.d/cfn-auto-reloader.conf"]} + } + } + }, + + "Configure" : { + "commands" : { + "01_set_mysql_root_password" : { + "command" : { "Fn::Join" : ["", ["mysqladmin -u root password '", { "Ref" : "DBRootPassword" }, "'"]]}, + "test" : { "Fn::Join" : ["", ["$(mysql ", { "Ref" : "DBName" }, " -u root --password='", { "Ref" : "DBRootPassword" }, "' >/dev/null 2>&1 /dev/null 2>&1 { - // TODO: Add the test after pipeline expects it - }), - ), -); From 5984f1a97b0f543d1775bfe0aa20fd659072bf7e Mon Sep 17 00:00:00 2001 From: Hogan Bobertz Date: Tue, 19 Sep 2023 15:15:17 -0400 Subject: [PATCH 05/39] integ test for CDK migrate --- .../resources/templates/ddbStack.json | 70 +++ .../tests/cli-integ-tests/cli.integtest.ts | 56 +-- .../tests/cli-integ-tests/template.txt | 414 ------------------ 3 files changed, 100 insertions(+), 440 deletions(-) create mode 100644 packages/@aws-cdk-testing/cli-integ/resources/templates/ddbStack.json delete mode 100644 packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/template.txt diff --git a/packages/@aws-cdk-testing/cli-integ/resources/templates/ddbStack.json b/packages/@aws-cdk-testing/cli-integ/resources/templates/ddbStack.json new file mode 100644 index 0000000000000..5613d7c4b0fcb --- /dev/null +++ b/packages/@aws-cdk-testing/cli-integ/resources/templates/ddbStack.json @@ -0,0 +1,70 @@ +{ + "AWSTemplateFormatVersion" : "2010-09-09", + + "Description" : "AWS CloudFormation Sample Template DynamoDB_Table: This template demonstrates the creation of a DynamoDB table. **WARNING** This template creates an Amazon DynamoDB table. You will be billed for the AWS resources used if you create a stack from this template.", + + "Parameters" : { + "HashKeyElementName" : { + "Description" : "HashType PrimaryKey Name", + "Type" : "String", + "AllowedPattern" : "[a-zA-Z0-9]*", + "MinLength": "1", + "MaxLength": "2048", + "ConstraintDescription" : "must contain only alphanumberic characters" + }, + + "HashKeyElementType" : { + "Description" : "HashType PrimaryKey Type", + "Type" : "String", + "Default" : "S", + "AllowedPattern" : "[S|N]", + "MinLength": "1", + "MaxLength": "1", + "ConstraintDescription" : "must be either S or N" + }, + + "ReadCapacityUnits" : { + "Description" : "Provisioned read throughput", + "Type" : "Number", + "Default" : "5", + "MinValue": "5", + "MaxValue": "10000", + "ConstraintDescription" : "must be between 5 and 10000" + }, + + "WriteCapacityUnits" : { + "Description" : "Provisioned write throughput", + "Type" : "Number", + "Default" : "10", + "MinValue": "5", + "MaxValue": "10000", + "ConstraintDescription" : "must be between 5 and 10000" + } + }, + + "Resources" : { + "myDynamoDBTable" : { + "Type" : "AWS::DynamoDB::Table", + "Properties" : { + "AttributeDefinitions": [ { + "AttributeName" : {"Ref" : "HashKeyElementName"}, + "AttributeType" : {"Ref" : "HashKeyElementType"} + } ], + "KeySchema": [ + { "AttributeName": {"Ref" : "HashKeyElementName"}, "KeyType": "HASH" } + ], + "ProvisionedThroughput" : { + "ReadCapacityUnits" : {"Ref" : "ReadCapacityUnits"}, + "WriteCapacityUnits" : {"Ref" : "WriteCapacityUnits"} + } + } + } + }, + + "Outputs" : { + "TableName" : { + "Value" : {"Ref" : "myDynamoDBTable"}, + "Description" : "Table name of the newly created DynamoDB table" + } + } +} diff --git a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts index ac965944af314..922dee3aa6f61 100644 --- a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts +++ b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts @@ -1,7 +1,7 @@ import { promises as fs, existsSync } from 'fs'; import * as os from 'os'; import * as path from 'path'; -import { integTest, cloneDirectory, shell, withDefaultFixture, retry, sleep, randomInteger, withSamIntegrationFixture, RESOURCES_DIR, withTemporaryDirectory, ShellHelper, withPackages } from '../../lib'; +import { integTest, cloneDirectory, shell, withDefaultFixture, retry, sleep, randomInteger, withSamIntegrationFixture, RESOURCES_DIR } from '../../lib'; jest.setTimeout(2 * 60 * 60_000); // Includes the time to acquire locks, worst-case single-threaded runtime @@ -50,31 +50,6 @@ integTest('VPC Lookup', withDefaultFixture(async (fixture) => { await fixture.cdkDeploy('import-vpc', { modEnv: { ENABLE_VPC_TESTING: 'IMPORT' } }); })); -integTest( - 'cdk migrate typescript', - withTemporaryDirectory( - withPackages(async (context) => { - - const tempShell = ShellHelper.fromContext(context); - await context.packages.makeCliAvailable(); - - const tempPath = path.resolve(context.integTestDir); - const inputFile = path.join(__dirname, 'template.txt'); - - await tempShell.shell([ - 'cdk', - 'migrate', - '-l', - 'typescript', - '--from-path', - inputFile, - '--output-path', - tempPath, - ]); - }), - ), -); - // testing a construct with a builtin Nodejs Lambda Function. // In this case we are testing the s3.Bucket construct with the // autoDeleteObjects prop set to true, which creates a Lambda backed @@ -596,6 +571,35 @@ integTest('deploy with role', withDefaultFixture(async (fixture) => { } })); +integTest( + 'cdk migrate typescript', + withDefaultFixture(async (fixture) => { + const tempPath = path.join(fixture.integTestDir); + + const inputFile = path.join(__dirname, '../../resources/templates/', 'ddbStack.json'); + + await fixture.cdk([ + 'migrate', + '--language', + 'typescript', + '--stack-name', + 'migrate-stack', + '--from-path', + inputFile.toString(), + '--output-path', + tempPath.toString(), + ]); + const stackArn = await fixture.cdk([ + 'deploy', + 'migrate-stack' + ]) + const response = await fixture.aws.cloudFormation('describeStacks', { + StackName: stackArn, + }); + expect(response.Stacks?.[0].StackStatus).toEqual('CREATE_COMPLETE'); + }), +); + integTest('cdk diff', withDefaultFixture(async (fixture) => { const diff1 = await fixture.cdk(['diff', fixture.fullStackName('test-1')]); expect(diff1).toContain('AWS::SNS::Topic'); diff --git a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/template.txt b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/template.txt deleted file mode 100644 index 29b4ea3689351..0000000000000 --- a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/template.txt +++ /dev/null @@ -1,414 +0,0 @@ -{ - "AWSTemplateFormatVersion" : "2010-09-09", - - "Description" : "AWS CloudFormation Sample Template LAMP_Single_Instance: Create a LAMP stack using a single EC2 instance and a local MySQL database for storage. This template demonstrates using the AWS CloudFormation bootstrap scripts to install the packages and files necessary to deploy the Apache web server, PHP and MySQL at instance launch time. **WARNING** This template creates an Amazon EC2 instance. You will be billed for the AWS resources used if you create a stack from this template.", - - "Parameters" : { - - "KeyName": { - "Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instance", - "Type": "AWS::EC2::KeyPair::KeyName", - "ConstraintDescription" : "must be the name of an existing EC2 KeyPair." - }, - - "DBName": { - "Default": "MyDatabase", - "Description" : "MySQL database name", - "Type": "String", - "MinLength": "1", - "MaxLength": "64", - "AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*", - "ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters." - }, - - "DBUser": { - "NoEcho": "true", - "Description" : "Username for MySQL database access", - "Type": "String", - "MinLength": "1", - "MaxLength": "16", - "AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*", - "ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters." - }, - - "DBPassword": { - "NoEcho": "true", - "Description" : "Password for MySQL database access", - "Type": "String", - "MinLength": "1", - "MaxLength": "41", - "AllowedPattern" : "[a-zA-Z0-9]*", - "ConstraintDescription" : "must contain only alphanumeric characters." - }, - - "DBRootPassword": { - "NoEcho": "true", - "Description" : "Root password for MySQL", - "Type": "String", - "MinLength": "1", - "MaxLength": "41", - "AllowedPattern" : "[a-zA-Z0-9]*", - "ConstraintDescription" : "must contain only alphanumeric characters." - }, - - "InstanceType" : { - "Description" : "WebServer EC2 instance type", - "Type" : "String", - "Default" : "t2.small", - "AllowedValues" : [ "t1.micro", "t2.nano", "t2.micro", "t2.small", "t2.medium", "t2.large", "m1.small", "m1.medium", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "m3.medium", "m3.large", "m3.xlarge", "m3.2xlarge", "m4.large", "m4.xlarge", "m4.2xlarge", "m4.4xlarge", "m4.10xlarge", "c1.medium", "c1.xlarge", "c3.large", "c3.xlarge", "c3.2xlarge", "c3.4xlarge", "c3.8xlarge", "c4.large", "c4.xlarge", "c4.2xlarge", "c4.4xlarge", "c4.8xlarge", "g2.2xlarge", "g2.8xlarge", "r3.large", "r3.xlarge", "r3.2xlarge", "r3.4xlarge", "r3.8xlarge", "i2.xlarge", "i2.2xlarge", "i2.4xlarge", "i2.8xlarge", "d2.xlarge", "d2.2xlarge", "d2.4xlarge", "d2.8xlarge", "hi1.4xlarge", "hs1.8xlarge", "cr1.8xlarge", "cc2.8xlarge", "cg1.4xlarge"] -, - "ConstraintDescription" : "must be a valid EC2 instance type." - }, - - "SSHLocation" : { - "Description" : " The IP address range that can be used to SSH to the EC2 instances", - "Type": "String", - "MinLength": "9", - "MaxLength": "18", - "Default": "0.0.0.0/0", - "AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})", - "ConstraintDescription": "must be a valid IP CIDR range of the form x.x.x.x/x." - } - }, - - "Mappings" : { - "AWSInstanceType2Arch" : { - "t1.micro" : { "Arch" : "HVM64" }, - "t2.nano" : { "Arch" : "HVM64" }, - "t2.micro" : { "Arch" : "HVM64" }, - "t2.small" : { "Arch" : "HVM64" }, - "t2.medium" : { "Arch" : "HVM64" }, - "t2.large" : { "Arch" : "HVM64" }, - "m1.small" : { "Arch" : "HVM64" }, - "m1.medium" : { "Arch" : "HVM64" }, - "m1.large" : { "Arch" : "HVM64" }, - "m1.xlarge" : { "Arch" : "HVM64" }, - "m2.xlarge" : { "Arch" : "HVM64" }, - "m2.2xlarge" : { "Arch" : "HVM64" }, - "m2.4xlarge" : { "Arch" : "HVM64" }, - "m3.medium" : { "Arch" : "HVM64" }, - "m3.large" : { "Arch" : "HVM64" }, - "m3.xlarge" : { "Arch" : "HVM64" }, - "m3.2xlarge" : { "Arch" : "HVM64" }, - "m4.large" : { "Arch" : "HVM64" }, - "m4.xlarge" : { "Arch" : "HVM64" }, - "m4.2xlarge" : { "Arch" : "HVM64" }, - "m4.4xlarge" : { "Arch" : "HVM64" }, - "m4.10xlarge" : { "Arch" : "HVM64" }, - "c1.medium" : { "Arch" : "HVM64" }, - "c1.xlarge" : { "Arch" : "HVM64" }, - "c3.large" : { "Arch" : "HVM64" }, - "c3.xlarge" : { "Arch" : "HVM64" }, - "c3.2xlarge" : { "Arch" : "HVM64" }, - "c3.4xlarge" : { "Arch" : "HVM64" }, - "c3.8xlarge" : { "Arch" : "HVM64" }, - "c4.large" : { "Arch" : "HVM64" }, - "c4.xlarge" : { "Arch" : "HVM64" }, - "c4.2xlarge" : { "Arch" : "HVM64" }, - "c4.4xlarge" : { "Arch" : "HVM64" }, - "c4.8xlarge" : { "Arch" : "HVM64" }, - "g2.2xlarge" : { "Arch" : "HVMG2" }, - "g2.8xlarge" : { "Arch" : "HVMG2" }, - "r3.large" : { "Arch" : "HVM64" }, - "r3.xlarge" : { "Arch" : "HVM64" }, - "r3.2xlarge" : { "Arch" : "HVM64" }, - "r3.4xlarge" : { "Arch" : "HVM64" }, - "r3.8xlarge" : { "Arch" : "HVM64" }, - "i2.xlarge" : { "Arch" : "HVM64" }, - "i2.2xlarge" : { "Arch" : "HVM64" }, - "i2.4xlarge" : { "Arch" : "HVM64" }, - "i2.8xlarge" : { "Arch" : "HVM64" }, - "d2.xlarge" : { "Arch" : "HVM64" }, - "d2.2xlarge" : { "Arch" : "HVM64" }, - "d2.4xlarge" : { "Arch" : "HVM64" }, - "d2.8xlarge" : { "Arch" : "HVM64" }, - "hi1.4xlarge" : { "Arch" : "HVM64" }, - "hs1.8xlarge" : { "Arch" : "HVM64" }, - "cr1.8xlarge" : { "Arch" : "HVM64" }, - "cc2.8xlarge" : { "Arch" : "HVM64" } - }, - - "AWSInstanceType2NATArch" : { - "t1.micro" : { "Arch" : "NATHVM64" }, - "t2.nano" : { "Arch" : "NATHVM64" }, - "t2.micro" : { "Arch" : "NATHVM64" }, - "t2.small" : { "Arch" : "NATHVM64" }, - "t2.medium" : { "Arch" : "NATHVM64" }, - "t2.large" : { "Arch" : "NATHVM64" }, - "m1.small" : { "Arch" : "NATHVM64" }, - "m1.medium" : { "Arch" : "NATHVM64" }, - "m1.large" : { "Arch" : "NATHVM64" }, - "m1.xlarge" : { "Arch" : "NATHVM64" }, - "m2.xlarge" : { "Arch" : "NATHVM64" }, - "m2.2xlarge" : { "Arch" : "NATHVM64" }, - "m2.4xlarge" : { "Arch" : "NATHVM64" }, - "m3.medium" : { "Arch" : "NATHVM64" }, - "m3.large" : { "Arch" : "NATHVM64" }, - "m3.xlarge" : { "Arch" : "NATHVM64" }, - "m3.2xlarge" : { "Arch" : "NATHVM64" }, - "m4.large" : { "Arch" : "NATHVM64" }, - "m4.xlarge" : { "Arch" : "NATHVM64" }, - "m4.2xlarge" : { "Arch" : "NATHVM64" }, - "m4.4xlarge" : { "Arch" : "NATHVM64" }, - "m4.10xlarge" : { "Arch" : "NATHVM64" }, - "c1.medium" : { "Arch" : "NATHVM64" }, - "c1.xlarge" : { "Arch" : "NATHVM64" }, - "c3.large" : { "Arch" : "NATHVM64" }, - "c3.xlarge" : { "Arch" : "NATHVM64" }, - "c3.2xlarge" : { "Arch" : "NATHVM64" }, - "c3.4xlarge" : { "Arch" : "NATHVM64" }, - "c3.8xlarge" : { "Arch" : "NATHVM64" }, - "c4.large" : { "Arch" : "NATHVM64" }, - "c4.xlarge" : { "Arch" : "NATHVM64" }, - "c4.2xlarge" : { "Arch" : "NATHVM64" }, - "c4.4xlarge" : { "Arch" : "NATHVM64" }, - "c4.8xlarge" : { "Arch" : "NATHVM64" }, - "g2.2xlarge" : { "Arch" : "NATHVMG2" }, - "g2.8xlarge" : { "Arch" : "NATHVMG2" }, - "r3.large" : { "Arch" : "NATHVM64" }, - "r3.xlarge" : { "Arch" : "NATHVM64" }, - "r3.2xlarge" : { "Arch" : "NATHVM64" }, - "r3.4xlarge" : { "Arch" : "NATHVM64" }, - "r3.8xlarge" : { "Arch" : "NATHVM64" }, - "i2.xlarge" : { "Arch" : "NATHVM64" }, - "i2.2xlarge" : { "Arch" : "NATHVM64" }, - "i2.4xlarge" : { "Arch" : "NATHVM64" }, - "i2.8xlarge" : { "Arch" : "NATHVM64" }, - "d2.xlarge" : { "Arch" : "NATHVM64" }, - "d2.2xlarge" : { "Arch" : "NATHVM64" }, - "d2.4xlarge" : { "Arch" : "NATHVM64" }, - "d2.8xlarge" : { "Arch" : "NATHVM64" }, - "hi1.4xlarge" : { "Arch" : "NATHVM64" }, - "hs1.8xlarge" : { "Arch" : "NATHVM64" }, - "cr1.8xlarge" : { "Arch" : "NATHVM64" }, - "cc2.8xlarge" : { "Arch" : "NATHVM64" } - } -, - "AWSRegionArch2AMI" : { - "af-south-1" : {"HVM64" : "ami-064cc455f8a1ef504", "HVMG2" : "NOT_SUPPORTED"}, - "ap-east-1" : {"HVM64" : "ami-f85b1989", "HVMG2" : "NOT_SUPPORTED"}, - "ap-northeast-1" : {"HVM64" : "ami-0b2c2a754d5b4da22", "HVMG2" : "ami-09d0e0e099ecabba2"}, - "ap-northeast-2" : {"HVM64" : "ami-0493ab99920f410fc", "HVMG2" : "NOT_SUPPORTED"}, - "ap-northeast-3" : {"HVM64" : "ami-01344f6f63a4decc1", "HVMG2" : "NOT_SUPPORTED"}, - "ap-south-1" : {"HVM64" : "ami-03cfb5e1fb4fac428", "HVMG2" : "ami-0244c1d42815af84a"}, - "ap-southeast-1" : {"HVM64" : "ami-0ba35dc9caf73d1c7", "HVMG2" : "ami-0e46ce0d6a87dc979"}, - "ap-southeast-2" : {"HVM64" : "ami-0ae99b503e8694028", "HVMG2" : "ami-0c0ab057a101d8ff2"}, - "ca-central-1" : {"HVM64" : "ami-0803e21a2ec22f953", "HVMG2" : "NOT_SUPPORTED"}, - "cn-north-1" : {"HVM64" : "ami-07a3f215cc90c889c", "HVMG2" : "NOT_SUPPORTED"}, - "cn-northwest-1" : {"HVM64" : "ami-0a3b3b10f714a0ff4", "HVMG2" : "NOT_SUPPORTED"}, - "eu-central-1" : {"HVM64" : "ami-0474863011a7d1541", "HVMG2" : "ami-0aa1822e3eb913a11"}, - "eu-north-1" : {"HVM64" : "ami-0de4b8910494dba0f", "HVMG2" : "ami-32d55b4c"}, - "eu-south-1" : {"HVM64" : "ami-08427144fe9ebdef6", "HVMG2" : "NOT_SUPPORTED"}, - "eu-west-1" : {"HVM64" : "ami-015232c01a82b847b", "HVMG2" : "ami-0d5299b1c6112c3c7"}, - "eu-west-2" : {"HVM64" : "ami-0765d48d7e15beb93", "HVMG2" : "NOT_SUPPORTED"}, - "eu-west-3" : {"HVM64" : "ami-0caf07637eda19d9c", "HVMG2" : "NOT_SUPPORTED"}, - "me-south-1" : {"HVM64" : "ami-0744743d80915b497", "HVMG2" : "NOT_SUPPORTED"}, - "sa-east-1" : {"HVM64" : "ami-0a52e8a6018e92bb0", "HVMG2" : "NOT_SUPPORTED"}, - "us-east-1" : {"HVM64" : "ami-032930428bf1abbff", "HVMG2" : "ami-0aeb704d503081ea6"}, - "us-east-2" : {"HVM64" : "ami-027cab9a7bf0155df", "HVMG2" : "NOT_SUPPORTED"}, - "us-west-1" : {"HVM64" : "ami-088c153f74339f34c", "HVMG2" : "ami-0a7fc72dc0e51aa77"}, - "us-west-2" : {"HVM64" : "ami-01fee56b22f308154", "HVMG2" : "ami-0fe84a5b4563d8f27"} - } - - }, - - "Resources" : { - - "WebServerInstance": { - "Type": "AWS::EC2::Instance", - "Metadata" : { - "AWS::CloudFormation::Init" : { - "configSets" : { - "InstallAndRun" : [ "Install", "Configure" ] - }, - - "Install" : { - "packages" : { - "yum" : { - "mysql" : [], - "mysql-server" : [], - "mysql-libs" : [], - "httpd" : [], - "php" : [], - "php-mysql" : [] - } - }, - - "files" : { - "/var/www/html/index.php" : { - "content" : { "Fn::Join" : [ "", [ - "\n", - " \n", - " AWS CloudFormation PHP Sample\n", - " \n", - " \n", - " \n", - "

Welcome to the AWS CloudFormation PHP Sample

\n", - "

\n", - " \";\n", - " print date(\"g:i A l, F j Y.\");\n", - " ?>\n", - "

\n", - " \";\n", - " }\n", - " else\n", - " {\n", - " print \"Server = \" . $hostname . \"
\";\n", - " }\n", - " // Get the instance-id of the intance from the instance metadata\n", - " curl_setopt($curl_handle,CURLOPT_URL,'http://169.254.169.254/latest/meta-data/instance-id');\n", - " $instanceid = curl_exec($curl_handle);\n", - " if (empty($instanceid))\n", - " {\n", - " print \"Sorry, for some reason, we got no instance id back
\";\n", - " }\n", - " else\n", - " {\n", - " print \"EC2 instance-id = \" . $instanceid . \"
\";\n", - " }\n", - " $Database = \"localhost\";\n", - " $DBUser = \"", {"Ref" : "DBUser"}, "\";\n", - " $DBPassword = \"", {"Ref" : "DBPassword"}, "\";\n", - " print \"Database = \" . $Database . \"
\";\n", - " $dbconnection = mysql_connect($Database, $DBUser, $DBPassword)\n", - " or die(\"Could not connect: \" . mysql_error());\n", - " print (\"Connected to $Database successfully\");\n", - " mysql_close($dbconnection);\n", - " ?>\n", - "

PHP Information

\n", - "

\n", - " \n", - " \n", - "\n" - ]]}, - "mode" : "000600", - "owner" : "apache", - "group" : "apache" - }, - - "/tmp/setup.mysql" : { - "content" : { "Fn::Join" : ["", [ - "CREATE DATABASE ", { "Ref" : "DBName" }, ";\n", - "GRANT ALL ON ", { "Ref" : "DBName" }, ".* TO '", { "Ref" : "DBUser" }, "'@localhost IDENTIFIED BY '", { "Ref" : "DBPassword" }, "';\n" - ]]}, - "mode" : "000400", - "owner" : "root", - "group" : "root" - }, - "/etc/cfn/cfn-hup.conf" : { - "content" : { "Fn::Join" : ["", [ - "[main]\n", - "stack=", { "Ref" : "AWS::StackId" }, "\n", - "region=", { "Ref" : "AWS::Region" }, "\n" - ]]}, - "mode" : "000400", - "owner" : "root", - "group" : "root" - }, - - "/etc/cfn/hooks.d/cfn-auto-reloader.conf" : { - "content": { "Fn::Join" : ["", [ - "[cfn-auto-reloader-hook]\n", - "triggers=post.update\n", - "path=Resources.WebServerInstance.Metadata.AWS::CloudFormation::Init\n", - "action=/opt/aws/bin/cfn-init -v ", - " --stack ", { "Ref" : "AWS::StackName" }, - " --resource WebServerInstance ", - " --configsets InstallAndRun ", - " --region ", { "Ref" : "AWS::Region" }, "\n", - "runas=root\n" - ]]}, - "mode" : "000400", - "owner" : "root", - "group" : "root" - } - }, - - "services" : { - "sysvinit" : { - "mysqld" : { "enabled" : "true", "ensureRunning" : "true" }, - "httpd" : { "enabled" : "true", "ensureRunning" : "true" }, - "cfn-hup" : { "enabled" : "true", "ensureRunning" : "true", - "files" : ["/etc/cfn/cfn-hup.conf", "/etc/cfn/hooks.d/cfn-auto-reloader.conf"]} - } - } - }, - - "Configure" : { - "commands" : { - "01_set_mysql_root_password" : { - "command" : { "Fn::Join" : ["", ["mysqladmin -u root password '", { "Ref" : "DBRootPassword" }, "'"]]}, - "test" : { "Fn::Join" : ["", ["$(mysql ", { "Ref" : "DBName" }, " -u root --password='", { "Ref" : "DBRootPassword" }, "' >/dev/null 2>&1 /dev/null 2>&1 Date: Tue, 19 Sep 2023 15:57:40 -0400 Subject: [PATCH 06/39] test fixes --- .../cli-integ/tests/cli-integ-tests/cli.integtest.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts index 922dee3aa6f61..537b45ac0ef34 100644 --- a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts +++ b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts @@ -591,8 +591,8 @@ integTest( ]); const stackArn = await fixture.cdk([ 'deploy', - 'migrate-stack' - ]) + 'migrate-stack', + ]); const response = await fixture.aws.cloudFormation('describeStacks', { StackName: stackArn, }); From 7c8ff720287b1d6d0d4806c94dc0ec638b92e18e Mon Sep 17 00:00:00 2001 From: Hogan Bobertz Date: Wed, 20 Sep 2023 12:16:03 -0400 Subject: [PATCH 07/39] working migrate test --- .../resources/templates/ddbStack.json | 70 ---------------- .../resources/templates/simpleDDB.yaml | 79 +++++++++++++++++++ .../tests/cli-integ-tests/cli.integtest.ts | 19 +++-- 3 files changed, 91 insertions(+), 77 deletions(-) delete mode 100644 packages/@aws-cdk-testing/cli-integ/resources/templates/ddbStack.json create mode 100644 packages/@aws-cdk-testing/cli-integ/resources/templates/simpleDDB.yaml diff --git a/packages/@aws-cdk-testing/cli-integ/resources/templates/ddbStack.json b/packages/@aws-cdk-testing/cli-integ/resources/templates/ddbStack.json deleted file mode 100644 index 5613d7c4b0fcb..0000000000000 --- a/packages/@aws-cdk-testing/cli-integ/resources/templates/ddbStack.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "AWSTemplateFormatVersion" : "2010-09-09", - - "Description" : "AWS CloudFormation Sample Template DynamoDB_Table: This template demonstrates the creation of a DynamoDB table. **WARNING** This template creates an Amazon DynamoDB table. You will be billed for the AWS resources used if you create a stack from this template.", - - "Parameters" : { - "HashKeyElementName" : { - "Description" : "HashType PrimaryKey Name", - "Type" : "String", - "AllowedPattern" : "[a-zA-Z0-9]*", - "MinLength": "1", - "MaxLength": "2048", - "ConstraintDescription" : "must contain only alphanumberic characters" - }, - - "HashKeyElementType" : { - "Description" : "HashType PrimaryKey Type", - "Type" : "String", - "Default" : "S", - "AllowedPattern" : "[S|N]", - "MinLength": "1", - "MaxLength": "1", - "ConstraintDescription" : "must be either S or N" - }, - - "ReadCapacityUnits" : { - "Description" : "Provisioned read throughput", - "Type" : "Number", - "Default" : "5", - "MinValue": "5", - "MaxValue": "10000", - "ConstraintDescription" : "must be between 5 and 10000" - }, - - "WriteCapacityUnits" : { - "Description" : "Provisioned write throughput", - "Type" : "Number", - "Default" : "10", - "MinValue": "5", - "MaxValue": "10000", - "ConstraintDescription" : "must be between 5 and 10000" - } - }, - - "Resources" : { - "myDynamoDBTable" : { - "Type" : "AWS::DynamoDB::Table", - "Properties" : { - "AttributeDefinitions": [ { - "AttributeName" : {"Ref" : "HashKeyElementName"}, - "AttributeType" : {"Ref" : "HashKeyElementType"} - } ], - "KeySchema": [ - { "AttributeName": {"Ref" : "HashKeyElementName"}, "KeyType": "HASH" } - ], - "ProvisionedThroughput" : { - "ReadCapacityUnits" : {"Ref" : "ReadCapacityUnits"}, - "WriteCapacityUnits" : {"Ref" : "WriteCapacityUnits"} - } - } - } - }, - - "Outputs" : { - "TableName" : { - "Value" : {"Ref" : "myDynamoDBTable"}, - "Description" : "Table name of the newly created DynamoDB table" - } - } -} diff --git a/packages/@aws-cdk-testing/cli-integ/resources/templates/simpleDDB.yaml b/packages/@aws-cdk-testing/cli-integ/resources/templates/simpleDDB.yaml new file mode 100644 index 0000000000000..f7a320b33dfa4 --- /dev/null +++ b/packages/@aws-cdk-testing/cli-integ/resources/templates/simpleDDB.yaml @@ -0,0 +1,79 @@ +AWSTemplateFormatVersion: "2010-09-09" +Resources: + myDynamoDBTable: + Type: AWS::DynamoDB::Table + Properties: + AttributeDefinitions: + - + AttributeName: "Album" + AttributeType: "S" + - + AttributeName: "Artist" + AttributeType: "S" + - + AttributeName: "Sales" + AttributeType: "N" + - + AttributeName: "NumberOfSongs" + AttributeType: "N" + KeySchema: + - + AttributeName: "Album" + KeyType: "HASH" + - + AttributeName: "Artist" + KeyType: "RANGE" + ProvisionedThroughput: + ReadCapacityUnits: "5" + WriteCapacityUnits: "5" + TableName: "myTableName" + GlobalSecondaryIndexes: + - + IndexName: "myGSI" + KeySchema: + - + AttributeName: "Sales" + KeyType: "HASH" + - + AttributeName: "Artist" + KeyType: "RANGE" + Projection: + NonKeyAttributes: + - "Album" + - "NumberOfSongs" + ProjectionType: "INCLUDE" + ProvisionedThroughput: + ReadCapacityUnits: "5" + WriteCapacityUnits: "5" + - + IndexName: "myGSI2" + KeySchema: + - + AttributeName: "NumberOfSongs" + KeyType: "HASH" + - + AttributeName: "Sales" + KeyType: "RANGE" + Projection: + NonKeyAttributes: + - "Album" + - "Artist" + ProjectionType: "INCLUDE" + ProvisionedThroughput: + ReadCapacityUnits: "5" + WriteCapacityUnits: "5" + LocalSecondaryIndexes: + - + IndexName: "myLSI" + KeySchema: + - + AttributeName: "Album" + KeyType: "HASH" + - + AttributeName: "Sales" + KeyType: "RANGE" + Projection: + NonKeyAttributes: + - "Artist" + - "NumberOfSongs" + ProjectionType: "INCLUDE" \ No newline at end of file diff --git a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts index 537b45ac0ef34..5df397c1f3e2e 100644 --- a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts +++ b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts @@ -1,7 +1,7 @@ import { promises as fs, existsSync } from 'fs'; import * as os from 'os'; import * as path from 'path'; -import { integTest, cloneDirectory, shell, withDefaultFixture, retry, sleep, randomInteger, withSamIntegrationFixture, RESOURCES_DIR } from '../../lib'; +import { integTest, cloneDirectory, shell, withDefaultFixture, retry, sleep, randomInteger, withSamIntegrationFixture, RESOURCES_DIR, TestFixture } from '../../lib'; jest.setTimeout(2 * 60 * 60_000); // Includes the time to acquire locks, worst-case single-threaded runtime @@ -576,27 +576,32 @@ integTest( withDefaultFixture(async (fixture) => { const tempPath = path.join(fixture.integTestDir); - const inputFile = path.join(__dirname, '../../resources/templates/', 'ddbStack.json'); + const inputFile = path.join(__dirname, '../../resources/templates/', 'simpleDDB.yaml'); + const stackName = fixture.stackNamePrefix + '-migrate-stack'; await fixture.cdk([ 'migrate', '--language', 'typescript', '--stack-name', - 'migrate-stack', + stackName, '--from-path', inputFile.toString(), '--output-path', tempPath.toString(), ]); - const stackArn = await fixture.cdk([ - 'deploy', - 'migrate-stack', - ]); + const tempFixture = new TestFixture( + path.join(tempPath.toString(), stackName), + fixture.stackNamePrefix, + fixture.output, + fixture.aws, + fixture.randomString); + const stackArn = await tempFixture.cdkDeploy('migrate-stack'); const response = await fixture.aws.cloudFormation('describeStacks', { StackName: stackArn, }); expect(response.Stacks?.[0].StackStatus).toEqual('CREATE_COMPLETE'); + await tempFixture.cdkDestroy('migrate-stack'); }), ); From 07b71e4101bbc1ddd3df4ae5f8403b8d31f42c1b Mon Sep 17 00:00:00 2001 From: Hogan Bobertz Date: Wed, 20 Sep 2023 12:57:06 -0400 Subject: [PATCH 08/39] add multi language support --- .../tests/cli-integ-tests/cli.integtest.ts | 69 ++++++++++--------- 1 file changed, 36 insertions(+), 33 deletions(-) diff --git a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts index 5df397c1f3e2e..724c0404e52ae 100644 --- a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts +++ b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts @@ -571,39 +571,42 @@ integTest('deploy with role', withDefaultFixture(async (fixture) => { } })); -integTest( - 'cdk migrate typescript', - withDefaultFixture(async (fixture) => { - const tempPath = path.join(fixture.integTestDir); - - const inputFile = path.join(__dirname, '../../resources/templates/', 'simpleDDB.yaml'); - const stackName = fixture.stackNamePrefix + '-migrate-stack'; - - await fixture.cdk([ - 'migrate', - '--language', - 'typescript', - '--stack-name', - stackName, - '--from-path', - inputFile.toString(), - '--output-path', - tempPath.toString(), - ]); - const tempFixture = new TestFixture( - path.join(tempPath.toString(), stackName), - fixture.stackNamePrefix, - fixture.output, - fixture.aws, - fixture.randomString); - const stackArn = await tempFixture.cdkDeploy('migrate-stack'); - const response = await fixture.aws.cloudFormation('describeStacks', { - StackName: stackArn, - }); - expect(response.Stacks?.[0].StackStatus).toEqual('CREATE_COMPLETE'); - await tempFixture.cdkDestroy('migrate-stack'); - }), -); +['typescript', 'python'].forEach(langChoice => { + integTest( + `cdk migrate ${langChoice}`, + withDefaultFixture(async (fixture) => { + const tempPath = path.join(fixture.integTestDir); + + const inputFile = path.join(__dirname, '../../resources/templates/', 'simpleDDB.yaml'); + const stackName = fixture.stackNamePrefix + `-${langChoice}-migrate-stack`; + + await fixture.cdk([ + 'migrate', + '--language', + `${langChoice}`, + '--stack-name', + stackName, + '--from-path', + inputFile.toString(), + '--output-path', + tempPath.toString(), + ]); + // Create a new fixture for the migrated app directory + const tempFixture = new TestFixture( + path.join(tempPath.toString(), stackName), + fixture.stackNamePrefix, + fixture.output, + fixture.aws, + fixture.randomString); + const stackArn = await tempFixture.cdkDeploy(`${langChoice}-migrate-stack`, { captureStderr: false }); + const response = await tempFixture.aws.cloudFormation('describeStacks', { + StackName: stackArn, + }); + expect(response.Stacks?.[0].StackStatus).toEqual('CREATE_COMPLETE'); + await tempFixture.cdkDestroy(`${langChoice}-migrate-stack`); + }), + ); +}); integTest('cdk diff', withDefaultFixture(async (fixture) => { const diff1 = await fixture.cdk(['diff', fixture.fullStackName('test-1')]); From 6f02a66ad4c9a9f6dc7779f0699ca6ba0963561d Mon Sep 17 00:00:00 2001 From: Hogan Bobertz Date: Wed, 20 Sep 2023 16:49:02 -0400 Subject: [PATCH 09/39] more testing templates and update to cdk-from-cfn --- .../@aws-cdk-testing/cli-integ/package.json | 8 +- .../templates/autoscaling-template.yml | 677 ++++++++++++++++++ .../resources/templates/sqs-template.json | 36 + .../tests/cli-integ-tests/cli.integtest.ts | 4 +- 4 files changed, 719 insertions(+), 6 deletions(-) create mode 100644 packages/@aws-cdk-testing/cli-integ/resources/templates/autoscaling-template.yml create mode 100644 packages/@aws-cdk-testing/cli-integ/resources/templates/sqs-template.json diff --git a/packages/@aws-cdk-testing/cli-integ/package.json b/packages/@aws-cdk-testing/cli-integ/package.json index b56f88fa4ea81..403ee627a1b48 100644 --- a/packages/@aws-cdk-testing/cli-integ/package.json +++ b/packages/@aws-cdk-testing/cli-integ/package.json @@ -1,7 +1,7 @@ { "name": "@aws-cdk-testing/cli-integ", "description": "Integration tests for the AWS CDK CLI", - "version": "0.0.0", + "version": "2.96.2", "bin": { "run-suite": "bin/run-suite", "download-and-run-old-tests": "bin/download-and-run-old-tests", @@ -29,13 +29,13 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/cdk-build-tools": "0.0.0", - "@types/semver": "^7.5.2", + "@aws-cdk/cdk-build-tools": "2.96.2-alpha.0", + "@types/semver": "^7.5.1", "@types/yargs": "^15.0.15", "@types/fs-extra": "^9.0.13", "@types/glob": "^7.2.0", "@types/npm": "^7.19.0", - "@aws-cdk/pkglint": "0.0.0" + "@aws-cdk/pkglint": "2.96.2-alpha.0" }, "dependencies": { "@octokit/rest": "^18.12.0", diff --git a/packages/@aws-cdk-testing/cli-integ/resources/templates/autoscaling-template.yml b/packages/@aws-cdk-testing/cli-integ/resources/templates/autoscaling-template.yml new file mode 100644 index 0000000000000..3178ee9558678 --- /dev/null +++ b/packages/@aws-cdk-testing/cli-integ/resources/templates/autoscaling-template.yml @@ -0,0 +1,677 @@ +AWSTemplateFormatVersion: 2010-09-09 +Description: >- + AWS CloudFormation Sample Template AutoScalingMultiAZWithNotifications: Create + a multi-az, load balanced and Auto Scaled sample web site running on an Apache + Web Serever. The application is configured to span all Availability Zones in + the region and is Auto-Scaled based on the CPU utilization of the web servers. + Notifications will be sent to the operator email address on scaling events. + The instances are load balanced with a simple health check against the default + web page. +Parameters: + VpcId: + Type: 'AWS::EC2::VPC::Id' + Description: VpcId of your existing Virtual Private Cloud (VPC) + ConstraintDescription: must be the VPC Id of an existing Virtual Private Cloud. + Subnets: + Type: 'List' + Description: The list of SubnetIds in your Virtual Private Cloud (VPC) + ConstraintDescription: >- + must be a list of at least two existing subnets associated with at least + two different availability zones. They should be residing in the selected + Virtual Private Cloud. + InstanceType: + Description: WebServer EC2 instance type + Type: String + Default: t2.small + AllowedValues: + - t1.micro + - t2.nano + - t2.micro + - t2.small + - t2.medium + - t2.large + - m1.small + - m1.medium + - m1.large + - m1.xlarge + - m2.xlarge + - m2.2xlarge + - m2.4xlarge + - m3.medium + - m3.large + - m3.xlarge + - m3.2xlarge + - m4.large + - m4.xlarge + - m4.2xlarge + - m4.4xlarge + - m4.10xlarge + - c1.medium + - c1.xlarge + - c3.large + - c3.xlarge + - c3.2xlarge + - c3.4xlarge + - c3.8xlarge + - c4.large + - c4.xlarge + - c4.2xlarge + - c4.4xlarge + - c4.8xlarge + - g2.2xlarge + - g2.8xlarge + - r3.large + - r3.xlarge + - r3.2xlarge + - r3.4xlarge + - r3.8xlarge + - i2.xlarge + - i2.2xlarge + - i2.4xlarge + - i2.8xlarge + - d2.xlarge + - d2.2xlarge + - d2.4xlarge + - d2.8xlarge + - hi1.4xlarge + - hs1.8xlarge + - cr1.8xlarge + - cc2.8xlarge + - cg1.4xlarge + ConstraintDescription: must be a valid EC2 instance type. + OperatorEMail: + Description: EMail address to notify if there are any scaling operations + Type: String + AllowedPattern: >- + ([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?) + ConstraintDescription: must be a valid email address. + KeyName: + Description: The EC2 Key Pair to allow SSH access to the instances + Type: 'AWS::EC2::KeyPair::KeyName' + ConstraintDescription: must be the name of an existing EC2 KeyPair. + SSHLocation: + Description: The IP address range that can be used to SSH to the EC2 instances + Type: String + MinLength: '9' + MaxLength: '18' + Default: 0.0.0.0/0 + AllowedPattern: '(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2})' + ConstraintDescription: must be a valid IP CIDR range of the form x.x.x.x/x. +Mappings: + Region2Examples: + ap-east-1: + Examples: 'https://s3-ap-east-1.amazonaws.com/cloudformation-examples-ap-east-1' + ap-northeast-1: + Examples: >- + https://s3-ap-northeast-1.amazonaws.com/cloudformation-examples-ap-northeast-1 + ap-northeast-2: + Examples: >- + https://s3-ap-northeast-2.amazonaws.com/cloudformation-examples-ap-northeast-2 + ap-northeast-3: + Examples: >- + https://s3-ap-northeast-3.amazonaws.com/cloudformation-examples-ap-northeast-3 + ap-south-1: + Examples: 'https://s3-ap-south-1.amazonaws.com/cloudformation-examples-ap-south-1' + ap-southeast-1: + Examples: >- + https://s3-ap-southeast-1.amazonaws.com/cloudformation-examples-ap-southeast-1 + ap-southeast-2: + Examples: >- + https://s3-ap-southeast-2.amazonaws.com/cloudformation-examples-ap-southeast-2 + ca-central-1: + Examples: >- + https://s3-ca-central-1.amazonaws.com/cloudformation-examples-ca-central-1 + cn-north-1: + Examples: >- + https://s3.cn-north-1.amazonaws.com.cn/cloudformation-examples-cn-north-1 + cn-northwest-1: + Examples: >- + https://s3.cn-northwest-1.amazonaws.com.cn/cloudformation-examples-cn-northwest-1 + eu-central-1: + Examples: >- + https://s3-eu-central-1.amazonaws.com/cloudformation-examples-eu-central-1 + eu-north-1: + Examples: 'https://s3-eu-north-1.amazonaws.com/cloudformation-examples-eu-north-1' + eu-west-1: + Examples: 'https://s3-eu-west-1.amazonaws.com/cloudformation-examples-eu-west-1' + eu-west-2: + Examples: 'https://s3-eu-west-2.amazonaws.com/cloudformation-examples-eu-west-2' + eu-west-3: + Examples: 'https://s3-eu-west-3.amazonaws.com/cloudformation-examples-eu-west-3' + me-south-1: + Examples: 'https://s3-me-south-1.amazonaws.com/cloudformation-examples-me-south-1' + sa-east-1: + Examples: 'https://s3-sa-east-1.amazonaws.com/cloudformation-examples-sa-east-1' + us-east-1: + Examples: 'https://s3.amazonaws.com/cloudformation-examples-us-east-1' + us-east-2: + Examples: 'https://s3-us-east-2.amazonaws.com/cloudformation-examples-us-east-2' + us-west-1: + Examples: 'https://s3-us-west-1.amazonaws.com/cloudformation-examples-us-west-1' + us-west-2: + Examples: 'https://s3-us-west-2.amazonaws.com/cloudformation-examples-us-west-2' + AWSInstanceType2Arch: + t1.micro: + Arch: HVM64 + t2.nano: + Arch: HVM64 + t2.micro: + Arch: HVM64 + t2.small: + Arch: HVM64 + t2.medium: + Arch: HVM64 + t2.large: + Arch: HVM64 + m1.small: + Arch: HVM64 + m1.medium: + Arch: HVM64 + m1.large: + Arch: HVM64 + m1.xlarge: + Arch: HVM64 + m2.xlarge: + Arch: HVM64 + m2.2xlarge: + Arch: HVM64 + m2.4xlarge: + Arch: HVM64 + m3.medium: + Arch: HVM64 + m3.large: + Arch: HVM64 + m3.xlarge: + Arch: HVM64 + m3.2xlarge: + Arch: HVM64 + m4.large: + Arch: HVM64 + m4.xlarge: + Arch: HVM64 + m4.2xlarge: + Arch: HVM64 + m4.4xlarge: + Arch: HVM64 + m4.10xlarge: + Arch: HVM64 + c1.medium: + Arch: HVM64 + c1.xlarge: + Arch: HVM64 + c3.large: + Arch: HVM64 + c3.xlarge: + Arch: HVM64 + c3.2xlarge: + Arch: HVM64 + c3.4xlarge: + Arch: HVM64 + c3.8xlarge: + Arch: HVM64 + c4.large: + Arch: HVM64 + c4.xlarge: + Arch: HVM64 + c4.2xlarge: + Arch: HVM64 + c4.4xlarge: + Arch: HVM64 + c4.8xlarge: + Arch: HVM64 + g2.2xlarge: + Arch: HVMG2 + g2.8xlarge: + Arch: HVMG2 + r3.large: + Arch: HVM64 + r3.xlarge: + Arch: HVM64 + r3.2xlarge: + Arch: HVM64 + r3.4xlarge: + Arch: HVM64 + r3.8xlarge: + Arch: HVM64 + i2.xlarge: + Arch: HVM64 + i2.2xlarge: + Arch: HVM64 + i2.4xlarge: + Arch: HVM64 + i2.8xlarge: + Arch: HVM64 + d2.xlarge: + Arch: HVM64 + d2.2xlarge: + Arch: HVM64 + d2.4xlarge: + Arch: HVM64 + d2.8xlarge: + Arch: HVM64 + hi1.4xlarge: + Arch: HVM64 + hs1.8xlarge: + Arch: HVM64 + cr1.8xlarge: + Arch: HVM64 + cc2.8xlarge: + Arch: HVM64 + AWSInstanceType2NATArch: + t1.micro: + Arch: NATHVM64 + t2.nano: + Arch: NATHVM64 + t2.micro: + Arch: NATHVM64 + t2.small: + Arch: NATHVM64 + t2.medium: + Arch: NATHVM64 + t2.large: + Arch: NATHVM64 + m1.small: + Arch: NATHVM64 + m1.medium: + Arch: NATHVM64 + m1.large: + Arch: NATHVM64 + m1.xlarge: + Arch: NATHVM64 + m2.xlarge: + Arch: NATHVM64 + m2.2xlarge: + Arch: NATHVM64 + m2.4xlarge: + Arch: NATHVM64 + m3.medium: + Arch: NATHVM64 + m3.large: + Arch: NATHVM64 + m3.xlarge: + Arch: NATHVM64 + m3.2xlarge: + Arch: NATHVM64 + m4.large: + Arch: NATHVM64 + m4.xlarge: + Arch: NATHVM64 + m4.2xlarge: + Arch: NATHVM64 + m4.4xlarge: + Arch: NATHVM64 + m4.10xlarge: + Arch: NATHVM64 + c1.medium: + Arch: NATHVM64 + c1.xlarge: + Arch: NATHVM64 + c3.large: + Arch: NATHVM64 + c3.xlarge: + Arch: NATHVM64 + c3.2xlarge: + Arch: NATHVM64 + c3.4xlarge: + Arch: NATHVM64 + c3.8xlarge: + Arch: NATHVM64 + c4.large: + Arch: NATHVM64 + c4.xlarge: + Arch: NATHVM64 + c4.2xlarge: + Arch: NATHVM64 + c4.4xlarge: + Arch: NATHVM64 + c4.8xlarge: + Arch: NATHVM64 + g2.2xlarge: + Arch: NATHVMG2 + g2.8xlarge: + Arch: NATHVMG2 + r3.large: + Arch: NATHVM64 + r3.xlarge: + Arch: NATHVM64 + r3.2xlarge: + Arch: NATHVM64 + r3.4xlarge: + Arch: NATHVM64 + r3.8xlarge: + Arch: NATHVM64 + i2.xlarge: + Arch: NATHVM64 + i2.2xlarge: + Arch: NATHVM64 + i2.4xlarge: + Arch: NATHVM64 + i2.8xlarge: + Arch: NATHVM64 + d2.xlarge: + Arch: NATHVM64 + d2.2xlarge: + Arch: NATHVM64 + d2.4xlarge: + Arch: NATHVM64 + d2.8xlarge: + Arch: NATHVM64 + hi1.4xlarge: + Arch: NATHVM64 + hs1.8xlarge: + Arch: NATHVM64 + cr1.8xlarge: + Arch: NATHVM64 + cc2.8xlarge: + Arch: NATHVM64 + AWSRegionArch2AMI: + af-south-1: + HVM64: ami-064cc455f8a1ef504 + HVMG2: NOT_SUPPORTED + ap-east-1: + HVM64: ami-f85b1989 + HVMG2: NOT_SUPPORTED + ap-northeast-1: + HVM64: ami-0b2c2a754d5b4da22 + HVMG2: ami-09d0e0e099ecabba2 + ap-northeast-2: + HVM64: ami-0493ab99920f410fc + HVMG2: NOT_SUPPORTED + ap-northeast-3: + HVM64: ami-01344f6f63a4decc1 + HVMG2: NOT_SUPPORTED + ap-south-1: + HVM64: ami-03cfb5e1fb4fac428 + HVMG2: ami-0244c1d42815af84a + ap-southeast-1: + HVM64: ami-0ba35dc9caf73d1c7 + HVMG2: ami-0e46ce0d6a87dc979 + ap-southeast-2: + HVM64: ami-0ae99b503e8694028 + HVMG2: ami-0c0ab057a101d8ff2 + ca-central-1: + HVM64: ami-0803e21a2ec22f953 + HVMG2: NOT_SUPPORTED + cn-north-1: + HVM64: ami-07a3f215cc90c889c + HVMG2: NOT_SUPPORTED + cn-northwest-1: + HVM64: ami-0a3b3b10f714a0ff4 + HVMG2: NOT_SUPPORTED + eu-central-1: + HVM64: ami-0474863011a7d1541 + HVMG2: ami-0aa1822e3eb913a11 + eu-north-1: + HVM64: ami-0de4b8910494dba0f + HVMG2: ami-32d55b4c + eu-south-1: + HVM64: ami-08427144fe9ebdef6 + HVMG2: NOT_SUPPORTED + eu-west-1: + HVM64: ami-015232c01a82b847b + HVMG2: ami-0d5299b1c6112c3c7 + eu-west-2: + HVM64: ami-0765d48d7e15beb93 + HVMG2: NOT_SUPPORTED + eu-west-3: + HVM64: ami-0caf07637eda19d9c + HVMG2: NOT_SUPPORTED + me-south-1: + HVM64: ami-0744743d80915b497 + HVMG2: NOT_SUPPORTED + sa-east-1: + HVM64: ami-0a52e8a6018e92bb0 + HVMG2: NOT_SUPPORTED + us-east-1: + HVM64: ami-032930428bf1abbff + HVMG2: ami-0aeb704d503081ea6 + us-east-2: + HVM64: ami-027cab9a7bf0155df + HVMG2: NOT_SUPPORTED + us-west-1: + HVM64: ami-088c153f74339f34c + HVMG2: ami-0a7fc72dc0e51aa77 + us-west-2: + HVM64: ami-01fee56b22f308154 + HVMG2: ami-0fe84a5b4563d8f27 +Resources: + NotificationTopic: + Type: 'AWS::SNS::Topic' + Properties: + Subscription: + - Endpoint: !Ref OperatorEMail + Protocol: email + WebServerGroup: + Type: 'AWS::AutoScaling::AutoScalingGroup' + Properties: + VPCZoneIdentifier: !Ref Subnets + LaunchConfigurationName: !Ref LaunchConfig + MinSize: '1' + MaxSize: '3' + TargetGroupARNs: + - !Ref ALBTargetGroup + NotificationConfiguration: + TopicARN: !Ref NotificationTopic + NotificationTypes: + - 'autoscaling:EC2_INSTANCE_LAUNCH' + - 'autoscaling:EC2_INSTANCE_LAUNCH_ERROR' + - 'autoscaling:EC2_INSTANCE_TERMINATE' + - 'autoscaling:EC2_INSTANCE_TERMINATE_ERROR' + CreationPolicy: + ResourceSignal: + Timeout: PT15M + Count: '1' + UpdatePolicy: + AutoScalingRollingUpdate: + MinInstancesInService: '1' + MaxBatchSize: '1' + PauseTime: PT15M + WaitOnResourceSignals: 'true' + LaunchConfig: + Type: 'AWS::AutoScaling::LaunchConfiguration' + Metadata: + Comment: Install a simple application + 'AWS::CloudFormation::Init': + config: + packages: + yum: + httpd: [] + files: + /var/www/html/index.html: + content: !Join + - |+ + + - - AWS CloudFormation Logo + - >- +

Congratulations, you have successfully launched the AWS + CloudFormation sample.

+ mode: '000644' + owner: root + group: root + /etc/cfn/cfn-hup.conf: + content: !Join + - '' + - - | + [main] + - stack= + - !Ref 'AWS::StackId' + - |+ + + - region= + - !Ref 'AWS::Region' + - |+ + + mode: '000400' + owner: root + group: root + /etc/cfn/hooks.d/cfn-auto-reloader.conf: + content: !Join + - '' + - - | + [cfn-auto-reloader-hook] + - | + triggers=post.update + - > + path=Resources.LaunchConfig.Metadata.AWS::CloudFormation::Init + - 'action=/opt/aws/bin/cfn-init -v ' + - ' --stack ' + - !Ref 'AWS::StackName' + - ' --resource LaunchConfig ' + - ' --region ' + - !Ref 'AWS::Region' + - |+ + + - | + runas=root + mode: '000400' + owner: root + group: root + services: + sysvinit: + httpd: + enabled: 'true' + ensureRunning: 'true' + cfn-hup: + enabled: 'true' + ensureRunning: 'true' + files: + - /etc/cfn/cfn-hup.conf + - /etc/cfn/hooks.d/cfn-auto-reloader.conf + Properties: + KeyName: !Ref KeyName + ImageId: !FindInMap + - AWSRegionArch2AMI + - !Ref 'AWS::Region' + - !FindInMap + - AWSInstanceType2Arch + - !Ref InstanceType + - Arch + SecurityGroups: + - !Ref InstanceSecurityGroup + InstanceType: !Ref InstanceType + UserData: !Base64 + 'Fn::Join': + - '' + - - | + #!/bin/bash -xe + - | + yum update -y aws-cfn-bootstrap + - | + yum update -y aws-cli + - '/opt/aws/bin/cfn-init -v ' + - ' --stack ' + - !Ref 'AWS::StackName' + - ' --resource LaunchConfig ' + - ' --region ' + - !Ref 'AWS::Region' + - |+ + + - '/opt/aws/bin/cfn-signal -e $? ' + - ' --stack ' + - !Ref 'AWS::StackName' + - ' --resource WebServerGroup ' + - ' --region ' + - !Ref 'AWS::Region' + - |+ + + WebServerScaleUpPolicy: + Type: 'AWS::AutoScaling::ScalingPolicy' + Properties: + AdjustmentType: ChangeInCapacity + AutoScalingGroupName: !Ref WebServerGroup + Cooldown: '60' + ScalingAdjustment: '1' + WebServerScaleDownPolicy: + Type: 'AWS::AutoScaling::ScalingPolicy' + Properties: + AdjustmentType: ChangeInCapacity + AutoScalingGroupName: !Ref WebServerGroup + Cooldown: '60' + ScalingAdjustment: '-1' + CPUAlarmHigh: + Type: 'AWS::CloudWatch::Alarm' + Properties: + AlarmDescription: Scale-up if CPU > 90% for 10 minutes + MetricName: CPUUtilization + Namespace: AWS/EC2 + Statistic: Average + Period: '300' + EvaluationPeriods: '2' + Threshold: '90' + AlarmActions: + - !Ref WebServerScaleUpPolicy + Dimensions: + - Name: AutoScalingGroupName + Value: !Ref WebServerGroup + ComparisonOperator: GreaterThanThreshold + CPUAlarmLow: + Type: 'AWS::CloudWatch::Alarm' + Properties: + AlarmDescription: Scale-down if CPU < 70% for 10 minutes + MetricName: CPUUtilization + Namespace: AWS/EC2 + Statistic: Average + Period: '300' + EvaluationPeriods: '2' + Threshold: '70' + AlarmActions: + - !Ref WebServerScaleDownPolicy + Dimensions: + - Name: AutoScalingGroupName + Value: !Ref WebServerGroup + ComparisonOperator: LessThanThreshold + ApplicationLoadBalancer: + Type: 'AWS::ElasticLoadBalancingV2::LoadBalancer' + Properties: + Subnets: !Ref Subnets + ALBListener: + Type: 'AWS::ElasticLoadBalancingV2::Listener' + Properties: + DefaultActions: + - Type: forward + TargetGroupArn: !Ref ALBTargetGroup + LoadBalancerArn: !Ref ApplicationLoadBalancer + Port: '80' + Protocol: HTTP + ALBTargetGroup: + Type: 'AWS::ElasticLoadBalancingV2::TargetGroup' + Properties: + HealthCheckIntervalSeconds: 30 + HealthCheckTimeoutSeconds: 5 + HealthyThresholdCount: 3 + Port: 80 + Protocol: HTTP + UnhealthyThresholdCount: 5 + VpcId: !Ref VpcId + InstanceSecurityGroup: + Type: 'AWS::EC2::SecurityGroup' + Properties: + GroupDescription: Enable SSH access and HTTP from the load balancer only + SecurityGroupIngress: + - IpProtocol: tcp + FromPort: '22' + ToPort: '22' + CidrIp: !Ref SSHLocation + - IpProtocol: tcp + FromPort: '80' + ToPort: '80' + SourceSecurityGroupId: !Select + - 0 + - !GetAtt + - ApplicationLoadBalancer + - SecurityGroups + VpcId: !Ref VpcId +Outputs: + URL: + Description: The URL of the website + Value: !Join + - '' + - - 'http://' + - !GetAtt + - ApplicationLoadBalancer + - DNSName \ No newline at end of file diff --git a/packages/@aws-cdk-testing/cli-integ/resources/templates/sqs-template.json b/packages/@aws-cdk-testing/cli-integ/resources/templates/sqs-template.json new file mode 100644 index 0000000000000..57c9ef5d12a3d --- /dev/null +++ b/packages/@aws-cdk-testing/cli-integ/resources/templates/sqs-template.json @@ -0,0 +1,36 @@ +{ + "AWSTemplateFormatVersion": "2010-09-09", + "Description": "AWS CloudFormation Sample Template SQS_With_CloudWatch_Alarms: Sample template showing how to create an SQS queue with AWS CloudWatch alarms on queue depth.", + "Resources": { + "MyQueue": { + "Type": "AWS::SQS::Queue", + "Properties": {} + } + }, + "Outputs": { + "QueueURL": { + "Description": "URL of newly created SQS Queue", + "Value": { + "Ref": "MyQueue" + } + }, + "QueueARN": { + "Description": "ARN of newly created SQS Queue", + "Value": { + "Fn::GetAtt": [ + "MyQueue", + "Arn" + ] + } + }, + "QueueName": { + "Description": "Name newly created SQS Queue", + "Value": { + "Fn::GetAtt": [ + "MyQueue", + "QueueName" + ] + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts index 724c0404e52ae..d48dc8888d3af 100644 --- a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts +++ b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts @@ -571,13 +571,13 @@ integTest('deploy with role', withDefaultFixture(async (fixture) => { } })); -['typescript', 'python'].forEach(langChoice => { +['typescript', 'python', 'csharp', 'java', 'go'].forEach(langChoice => { integTest( `cdk migrate ${langChoice}`, withDefaultFixture(async (fixture) => { const tempPath = path.join(fixture.integTestDir); - const inputFile = path.join(__dirname, '../../resources/templates/', 'simpleDDB.yaml'); + const inputFile = path.join(__dirname, '../../resources/templates/', 'sqs-template.json'); const stackName = fixture.stackNamePrefix + `-${langChoice}-migrate-stack`; await fixture.cdk([ From d995ab9abb4eab9f531602c97795dc681c6e7460 Mon Sep 17 00:00:00 2001 From: Hogan Bobertz Date: Thu, 21 Sep 2023 17:59:23 -0400 Subject: [PATCH 10/39] fix go stack name issue --- .../cli-integ/tests/cli-integ-tests/cli.integtest.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts index d48dc8888d3af..cd8167d098b7a 100644 --- a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts +++ b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts @@ -598,7 +598,16 @@ integTest('deploy with role', withDefaultFixture(async (fixture) => { fixture.output, fixture.aws, fixture.randomString); - const stackArn = await tempFixture.cdkDeploy(`${langChoice}-migrate-stack`, { captureStderr: false }); + if (langChoice == 'go') { + await tempFixture.shell(['go', 'get']); + } + // go stack doesn't follow the same naming scheme as other languages. + let stackArn; + if (langChoice == 'go') { + stackArn = await tempFixture.cdk(['deploy', '--require-approval', 'never'], { captureStderr: false }); + } else { + stackArn = await tempFixture.cdkDeploy(`${langChoice}-migrate-stack`, { captureStderr: false }); + } const response = await tempFixture.aws.cloudFormation('describeStacks', { StackName: stackArn, }); From 0772315e515b25d2e1735e2c2000fc640240b4d3 Mon Sep 17 00:00:00 2001 From: Hogan Bobertz Date: Thu, 21 Sep 2023 18:07:05 -0400 Subject: [PATCH 11/39] fix package.json version issue --- packages/@aws-cdk-testing/cli-integ/package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/@aws-cdk-testing/cli-integ/package.json b/packages/@aws-cdk-testing/cli-integ/package.json index 403ee627a1b48..b56f88fa4ea81 100644 --- a/packages/@aws-cdk-testing/cli-integ/package.json +++ b/packages/@aws-cdk-testing/cli-integ/package.json @@ -1,7 +1,7 @@ { "name": "@aws-cdk-testing/cli-integ", "description": "Integration tests for the AWS CDK CLI", - "version": "2.96.2", + "version": "0.0.0", "bin": { "run-suite": "bin/run-suite", "download-and-run-old-tests": "bin/download-and-run-old-tests", @@ -29,13 +29,13 @@ }, "license": "Apache-2.0", "devDependencies": { - "@aws-cdk/cdk-build-tools": "2.96.2-alpha.0", - "@types/semver": "^7.5.1", + "@aws-cdk/cdk-build-tools": "0.0.0", + "@types/semver": "^7.5.2", "@types/yargs": "^15.0.15", "@types/fs-extra": "^9.0.13", "@types/glob": "^7.2.0", "@types/npm": "^7.19.0", - "@aws-cdk/pkglint": "2.96.2-alpha.0" + "@aws-cdk/pkglint": "0.0.0" }, "dependencies": { "@octokit/rest": "^18.12.0", From a92fc50e2b9c80f6231fc71ff7605d5c94a90b6c Mon Sep 17 00:00:00 2001 From: Hogan Bobertz Date: Thu, 21 Sep 2023 18:18:48 -0400 Subject: [PATCH 12/39] csharp has too many stacks in it's name --- packages/aws-cdk/lib/commands/migrate.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk/lib/commands/migrate.ts b/packages/aws-cdk/lib/commands/migrate.ts index a1ca3248b9b35..fa42d91bd53a8 100644 --- a/packages/aws-cdk/lib/commands/migrate.ts +++ b/packages/aws-cdk/lib/commands/migrate.ts @@ -79,7 +79,7 @@ export async function generateCdkApp(stackName: string, stack: string, language: */ export function generateStack(template: string, stackName: string, language: string) { try { - const formattedStackName = `${camelCase(decamelize(stackName), { pascalCase: true })}Stack`; + const formattedStackName = `${camelCase(decamelize(stackName), { pascalCase: true })}` + language == 'csharp' ? '' : 'Stack'; return cdk_from_cfn.transmute(template, language, formattedStackName); } catch (e) { throw new Error(`stack generation failed due to error '${(e as Error).message}'`); From 2529935de6ae4fc7fccfe0768e2076f9def64fc0 Mon Sep 17 00:00:00 2001 From: Hogan Bobertz Date: Thu, 21 Sep 2023 18:27:49 -0400 Subject: [PATCH 13/39] modify cdk-from-cfn package versions --- packages/aws-cdk/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/aws-cdk/package.json b/packages/aws-cdk/package.json index 81eb3cf575aee..cdffc2b26ac9c 100644 --- a/packages/aws-cdk/package.json +++ b/packages/aws-cdk/package.json @@ -82,7 +82,7 @@ "aws-cdk-lib": "0.0.0", "aws-sdk-mock": "5.6.0", "axios": "^0.27.2", - "cdk-from-cfn": "^0.17.0", + "cdk-from-cfn": "^0.22.0", "constructs": "^10.0.0", "fast-check": "^3.13.0", "jest": "^29.7.0", @@ -105,7 +105,7 @@ "aws-sdk": "^2.1461.0", "camelcase": "^6.3.0", "cdk-assets": "0.0.0", - "cdk-from-cfn": "^0.17.0", + "cdk-from-cfn": "^0.22.0", "chalk": "^4", "chokidar": "^3.5.3", "decamelize": "^5.0.1", From 42cd3127bbde0683cf134f5dba24fd4787e31731 Mon Sep 17 00:00:00 2001 From: Hogan Bobertz Date: Thu, 21 Sep 2023 22:17:21 -0400 Subject: [PATCH 14/39] typescript does PEMDAS weirdly --- packages/aws-cdk/lib/commands/migrate.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk/lib/commands/migrate.ts b/packages/aws-cdk/lib/commands/migrate.ts index fa42d91bd53a8..2cb7a9b3ee1aa 100644 --- a/packages/aws-cdk/lib/commands/migrate.ts +++ b/packages/aws-cdk/lib/commands/migrate.ts @@ -79,7 +79,7 @@ export async function generateCdkApp(stackName: string, stack: string, language: */ export function generateStack(template: string, stackName: string, language: string) { try { - const formattedStackName = `${camelCase(decamelize(stackName), { pascalCase: true })}` + language == 'csharp' ? '' : 'Stack'; + const formattedStackName = `${camelCase(decamelize(stackName), { pascalCase: true })}` + (language == 'csharp' ? '' : 'Stack'); return cdk_from_cfn.transmute(template, language, formattedStackName); } catch (e) { throw new Error(`stack generation failed due to error '${(e as Error).message}'`); From 046bd4db0cdf0a3834a801cf0ee3866cc6c9f85f Mon Sep 17 00:00:00 2001 From: Hogan Bobertz Date: Fri, 22 Sep 2023 16:41:33 -0400 Subject: [PATCH 15/39] modify init template for csharp --- .../app/csharp/src/%name.PascalCased%/Program.template.cs | 2 +- packages/aws-cdk/lib/init.ts | 3 +++ packages/aws-cdk/package.json | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/aws-cdk/lib/init-templates/app/csharp/src/%name.PascalCased%/Program.template.cs b/packages/aws-cdk/lib/init-templates/app/csharp/src/%name.PascalCased%/Program.template.cs index 7099783ef9eac..917c0ae6f6139 100644 --- a/packages/aws-cdk/lib/init-templates/app/csharp/src/%name.PascalCased%/Program.template.cs +++ b/packages/aws-cdk/lib/init-templates/app/csharp/src/%name.PascalCased%/Program.template.cs @@ -10,7 +10,7 @@ sealed class Program public static void Main(string[] args) { var app = new App(); - new %name.PascalCased%Stack(app, "%stackname%", new StackProps + new %PascalStackName%(app, "%stackname%", new %PascalStackProps% { // If you don't specify 'env', this stack will be environment-agnostic. // Account/Region-dependent features and context lookups will not work, diff --git a/packages/aws-cdk/lib/init.ts b/packages/aws-cdk/lib/init.ts index 60c5173e04611..bfd108fae6e89 100644 --- a/packages/aws-cdk/lib/init.ts +++ b/packages/aws-cdk/lib/init.ts @@ -172,7 +172,10 @@ export class InitTemplate { break; } return template.replace(/%name%/g, project.name) + .replace(/%stackname%/, project.stackName ?? '%name.PascalCased%Stack') + .replace(/%PascalStackName%/, camelCase(project.stackName, { pascalCase: true }) ?? '%name.PascalCased%Stack') + .replace(/%PascalStackProps%/, (camelCase(project.stackName, { pascalCase: true }) + 'Props') ?? 'StackProps') .replace(/%name\.camelCased%/g, camelCase(project.name)) .replace(/%name\.PascalCased%/g, camelCase(project.name, { pascalCase: true })) .replace(/%cdk-version%/g, cdkVersion) diff --git a/packages/aws-cdk/package.json b/packages/aws-cdk/package.json index cdffc2b26ac9c..9ada98da84fb3 100644 --- a/packages/aws-cdk/package.json +++ b/packages/aws-cdk/package.json @@ -82,7 +82,7 @@ "aws-cdk-lib": "0.0.0", "aws-sdk-mock": "5.6.0", "axios": "^0.27.2", - "cdk-from-cfn": "^0.22.0", + "cdk-from-cfn": "^0.21.0", "constructs": "^10.0.0", "fast-check": "^3.13.0", "jest": "^29.7.0", @@ -105,7 +105,7 @@ "aws-sdk": "^2.1461.0", "camelcase": "^6.3.0", "cdk-assets": "0.0.0", - "cdk-from-cfn": "^0.22.0", + "cdk-from-cfn": "^0.21.0", "chalk": "^4", "chokidar": "^3.5.3", "decamelize": "^5.0.1", From a7aabde4ee79d2b317ec1e128bc7e8f7359134fb Mon Sep 17 00:00:00 2001 From: Hogan Bobertz Date: Fri, 22 Sep 2023 17:02:53 -0400 Subject: [PATCH 16/39] add 0.23.0 to yarn lock --- packages/aws-cdk/package.json | 4 ++-- yarn.lock | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/aws-cdk/package.json b/packages/aws-cdk/package.json index 3fc52f32b7c6f..e88fb17a66e94 100644 --- a/packages/aws-cdk/package.json +++ b/packages/aws-cdk/package.json @@ -82,7 +82,7 @@ "aws-cdk-lib": "0.0.0", "aws-sdk-mock": "5.6.0", "axios": "^0.27.2", - "cdk-from-cfn": "^0.21.0", + "cdk-from-cfn": "^0.23.0", "constructs": "^10.0.0", "fast-check": "^3.13.0", "jest": "^29.7.0", @@ -105,7 +105,7 @@ "aws-sdk": "^2.1461.0", "camelcase": "^6.3.0", "cdk-assets": "0.0.0", - "cdk-from-cfn": "^0.21.0", + "cdk-from-cfn": "^0.23.0", "chalk": "^4", "chokidar": "^3.5.3", "decamelize": "^5.0.1", diff --git a/yarn.lock b/yarn.lock index 90d0d5ceae99a..7f78f553a7756 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5334,10 +5334,10 @@ case@1.6.3, case@^1.6.3: resolved "https://registry.npmjs.org/case/-/case-1.6.3.tgz#0a4386e3e9825351ca2e6216c60467ff5f1ea1c9" integrity sha512-mzDSXIPaFwVDvZAHqZ9VlbyF4yyXRuX6IvB06WvPYkqJVO24kX1PPhv9bfpKNFZyxYFmmgo03HUiD8iklmJYRQ== -cdk-from-cfn@^0.17.0: - version "0.17.0" - resolved "https://registry.npmjs.org/cdk-from-cfn/-/cdk-from-cfn-0.17.0.tgz#46f77dc1141c21ee99255cdda59a8a2d2d428755" - integrity sha512-7sJnvEfnlFhYdIih4XZfIpUFiIy0ogdLXHk8BZEaWdG1tSpUOV9HTmk5IvZJr6YfF1j1D21kvrGLZYZNsRr7HA== +cdk-from-cfn@^0.23.0: + version "0.23.0" + resolved "https://registry.npmjs.org/cdk-from-cfn/-/cdk-from-cfn-0.23.0.tgz#2f825955ff8d79c5ecd6cf17d8beb22535e50c96" + integrity sha512-JOcTlr1x9aBi3UrG2BOJcMVWeBIOq+zFS8YDtdog6znKPjaM7ixTM3XXFT/u9UEP4q7AikmiqUE85ocrkKHgOg== cdk-generate-synthetic-examples@^0.1.291: version "0.1.291" From 0bfabe2c5ff83a3120360227003d34a514e760c5 Mon Sep 17 00:00:00 2001 From: Hogan Bobertz Date: Tue, 26 Sep 2023 10:12:49 -0400 Subject: [PATCH 17/39] fix THIRD_PARTY_LICENSCES --- packages/aws-cdk/THIRD_PARTY_LICENSES | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk/THIRD_PARTY_LICENSES b/packages/aws-cdk/THIRD_PARTY_LICENSES index b8a26fad2154f..8f42cbd123a57 100644 --- a/packages/aws-cdk/THIRD_PARTY_LICENSES +++ b/packages/aws-cdk/THIRD_PARTY_LICENSES @@ -461,7 +461,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI ---------------- -** cdk-from-cfn@0.17.0 - https://www.npmjs.com/package/cdk-from-cfn/v/0.17.0 | MIT OR Apache-2.0 +** cdk-from-cfn@0.23.0 - https://www.npmjs.com/package/cdk-from-cfn/v/0.23.0 | MIT OR Apache-2.0 ---------------- From db851025e5a83d0f5df896fc50e5a028d26fcbec Mon Sep 17 00:00:00 2001 From: Hogan Bobertz Date: Tue, 26 Sep 2023 10:13:50 -0400 Subject: [PATCH 18/39] remove random whitespace --- packages/aws-cdk/lib/init.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/aws-cdk/lib/init.ts b/packages/aws-cdk/lib/init.ts index bfd108fae6e89..cc343501f59d7 100644 --- a/packages/aws-cdk/lib/init.ts +++ b/packages/aws-cdk/lib/init.ts @@ -172,7 +172,6 @@ export class InitTemplate { break; } return template.replace(/%name%/g, project.name) - .replace(/%stackname%/, project.stackName ?? '%name.PascalCased%Stack') .replace(/%PascalStackName%/, camelCase(project.stackName, { pascalCase: true }) ?? '%name.PascalCased%Stack') .replace(/%PascalStackProps%/, (camelCase(project.stackName, { pascalCase: true }) + 'Props') ?? 'StackProps') From 01e1c62ecc06f8e688c6bc741eaf07086d37cdca Mon Sep 17 00:00:00 2001 From: Hogan Bobertz Date: Tue, 26 Sep 2023 10:29:11 -0400 Subject: [PATCH 19/39] modify Third party licensces in alpha lib --- packages/@aws-cdk/cli-lib-alpha/THIRD_PARTY_LICENSES | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@aws-cdk/cli-lib-alpha/THIRD_PARTY_LICENSES b/packages/@aws-cdk/cli-lib-alpha/THIRD_PARTY_LICENSES index cbae80964d512..b69cc62112f9b 100644 --- a/packages/@aws-cdk/cli-lib-alpha/THIRD_PARTY_LICENSES +++ b/packages/@aws-cdk/cli-lib-alpha/THIRD_PARTY_LICENSES @@ -461,7 +461,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI ---------------- -** cdk-from-cfn@0.17.0 - https://www.npmjs.com/package/cdk-from-cfn/v/0.17.0 | MIT OR Apache-2.0 +** cdk-from-cfn@0.23.0 - https://www.npmjs.com/package/cdk-from-cfn/v/0.23.0 | MIT OR Apache-2.0 ---------------- From 9b1cb627ab0681381bdd3e7d49fcb67df44a689a Mon Sep 17 00:00:00 2001 From: Hogan Bobertz Date: Tue, 26 Sep 2023 15:41:10 -0400 Subject: [PATCH 20/39] fix unit tests for new cdk-from-cfn version --- packages/aws-cdk/lib/commands/migrate.ts | 2 +- packages/aws-cdk/lib/init.ts | 4 ++-- packages/aws-cdk/test/commands/migrate.test.ts | 2 +- .../test/commands/test-resources/stacks/S3Stack.cs | 6 +++++- .../test/commands/test-resources/stacks/s3.go | 12 ++++++------ 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/packages/aws-cdk/lib/commands/migrate.ts b/packages/aws-cdk/lib/commands/migrate.ts index 2cb7a9b3ee1aa..a1ca3248b9b35 100644 --- a/packages/aws-cdk/lib/commands/migrate.ts +++ b/packages/aws-cdk/lib/commands/migrate.ts @@ -79,7 +79,7 @@ export async function generateCdkApp(stackName: string, stack: string, language: */ export function generateStack(template: string, stackName: string, language: string) { try { - const formattedStackName = `${camelCase(decamelize(stackName), { pascalCase: true })}` + (language == 'csharp' ? '' : 'Stack'); + const formattedStackName = `${camelCase(decamelize(stackName), { pascalCase: true })}Stack`; return cdk_from_cfn.transmute(template, language, formattedStackName); } catch (e) { throw new Error(`stack generation failed due to error '${(e as Error).message}'`); diff --git a/packages/aws-cdk/lib/init.ts b/packages/aws-cdk/lib/init.ts index cc343501f59d7..c903695403e19 100644 --- a/packages/aws-cdk/lib/init.ts +++ b/packages/aws-cdk/lib/init.ts @@ -173,8 +173,8 @@ export class InitTemplate { } return template.replace(/%name%/g, project.name) .replace(/%stackname%/, project.stackName ?? '%name.PascalCased%Stack') - .replace(/%PascalStackName%/, camelCase(project.stackName, { pascalCase: true }) ?? '%name.PascalCased%Stack') - .replace(/%PascalStackProps%/, (camelCase(project.stackName, { pascalCase: true }) + 'Props') ?? 'StackProps') + .replace(/%PascalStackName%/, project.stackName ? camelCase(project.stackName, { pascalCase: true }) : '%name.PascalCased%Stack') + .replace(/%PascalStackProps%/, project.stackName ? (camelCase(project.stackName, { pascalCase: true }) + 'Props') : 'StackProps') .replace(/%name\.camelCased%/g, camelCase(project.name)) .replace(/%name\.PascalCased%/g, camelCase(project.name, { pascalCase: true })) .replace(/%cdk-version%/g, cdkVersion) diff --git a/packages/aws-cdk/test/commands/migrate.test.ts b/packages/aws-cdk/test/commands/migrate.test.ts index 111ef36c2aa1a..1e17e7ac75800 100644 --- a/packages/aws-cdk/test/commands/migrate.test.ts +++ b/packages/aws-cdk/test/commands/migrate.test.ts @@ -177,7 +177,7 @@ describe('Migrate Function Tests', () => { // Replaced stack file is referenced correctly in app file const app = fs.readFileSync(path.join(workDir, 'GoodCSharp', 'src', 'GoodCSharp', 'Program.cs'), 'utf8').split('\n'); expect(app.map(line => line.match('namespace GoodCSharp')).filter(line => line).length).toEqual(1); - expect(app.map(line => line.match(/ new GoodCSharpStack\(app, "GoodCSharp", new StackProps/)).filter(line => line).length).toEqual(1); + expect(app.map(line => line.match(/ new GoodCSharp\(app, "GoodCSharp", new GoodCSharpProps/)).filter(line => line).length).toEqual(1); // Replaced stack file is correctly generated const replacedStack = fs.readFileSync(path.join(workDir, 'GoodCSharp', 'src', 'GoodCSharp', 'GoodCSharpStack.cs')); diff --git a/packages/aws-cdk/test/commands/test-resources/stacks/S3Stack.cs b/packages/aws-cdk/test/commands/test-resources/stacks/S3Stack.cs index 1b1a8a9b9dcc4..bc29e736d2482 100644 --- a/packages/aws-cdk/test/commands/test-resources/stacks/S3Stack.cs +++ b/packages/aws-cdk/test/commands/test-resources/stacks/S3Stack.cs @@ -3,8 +3,12 @@ using Constructs; using System.Collections.Generic; -namespace Com.Acme.Test.Simple +namespace GoodCSharpStack { + public class GoodCSharpStackProps : StackProps + { + } + /// /// AWS CloudFormation Sample Template S3_Website_Bucket_With_Retain_On_Delete: Sample template showing how to create a publicly accessible S3 bucket configured for website access with a deletion policy of retain on delete. /// diff --git a/packages/aws-cdk/test/commands/test-resources/stacks/s3.go b/packages/aws-cdk/test/commands/test-resources/stacks/s3.go index 2dbcdc6b98a3f..ea2a77e048635 100644 --- a/packages/aws-cdk/test/commands/test-resources/stacks/s3.go +++ b/packages/aws-cdk/test/commands/test-resources/stacks/s3.go @@ -48,10 +48,10 @@ func NewGoodGoStack(scope constructs.Construct, id string, props GoodGoStackProp func main() { defer jsii.Close() - app := awscdk.NewApp(nil) + app := cdk.NewApp(nil) - NewGoodGoStack(app, "GoodGo", &GoodGoStackProps{ - awscdk.StackProps{ + NewGoodGoStack(app, "GoodGo", GoodGoStackProps{ + cdk.StackProps{ Env: env(), }, }) @@ -61,7 +61,7 @@ func main() { // env determines the AWS environment (account+region) in which our stack is to // be deployed. For more information see: https://docs.aws.amazon.com/cdk/latest/guide/environments.html -func env() *awscdk.Environment { +func env() *cdk.Environment { // If unspecified, this stack will be "environment-agnostic". // Account/Region-dependent features and context lookups will not work, but a // single synthesized template can be deployed anywhere. @@ -71,7 +71,7 @@ func env() *awscdk.Environment { // Uncomment if you know exactly what account and region you want to deploy // the stack to. This is the recommendation for production stacks. //--------------------------------------------------------------------------- - // return &awscdk.Environment{ + // return &cdk.Environment{ // Account: jsii.String("123456789012"), // Region: jsii.String("us-east-1"), // } @@ -80,7 +80,7 @@ func env() *awscdk.Environment { // implied by the current CLI configuration. This is recommended for dev // stacks. //--------------------------------------------------------------------------- - // return &awscdk.Environment{ + // return &cdk.Environment{ // Account: jsii.String(os.Getenv("CDK_DEFAULT_ACCOUNT")), // Region: jsii.String(os.Getenv("CDK_DEFAULT_REGION")), // } From 70768d5ed6d512a0229cdb0c952912ee3644cea3 Mon Sep 17 00:00:00 2001 From: Hogan Bobertz Date: Tue, 26 Sep 2023 18:25:48 -0400 Subject: [PATCH 21/39] Conditionally add csharp stack name --- packages/aws-cdk/lib/commands/migrate.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk/lib/commands/migrate.ts b/packages/aws-cdk/lib/commands/migrate.ts index a1ca3248b9b35..2cb7a9b3ee1aa 100644 --- a/packages/aws-cdk/lib/commands/migrate.ts +++ b/packages/aws-cdk/lib/commands/migrate.ts @@ -79,7 +79,7 @@ export async function generateCdkApp(stackName: string, stack: string, language: */ export function generateStack(template: string, stackName: string, language: string) { try { - const formattedStackName = `${camelCase(decamelize(stackName), { pascalCase: true })}Stack`; + const formattedStackName = `${camelCase(decamelize(stackName), { pascalCase: true })}` + (language == 'csharp' ? '' : 'Stack'); return cdk_from_cfn.transmute(template, language, formattedStackName); } catch (e) { throw new Error(`stack generation failed due to error '${(e as Error).message}'`); From 321c23e96cc9abd1add01394eb427f7e53e9751e Mon Sep 17 00:00:00 2001 From: Hogan Bobertz Date: Tue, 26 Sep 2023 18:36:43 -0400 Subject: [PATCH 22/39] update S3Stack.cs snapshot --- .../test/commands/test-resources/stacks/S3Stack.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/aws-cdk/test/commands/test-resources/stacks/S3Stack.cs b/packages/aws-cdk/test/commands/test-resources/stacks/S3Stack.cs index bc29e736d2482..7204125037b2c 100644 --- a/packages/aws-cdk/test/commands/test-resources/stacks/S3Stack.cs +++ b/packages/aws-cdk/test/commands/test-resources/stacks/S3Stack.cs @@ -3,16 +3,16 @@ using Constructs; using System.Collections.Generic; -namespace GoodCSharpStack +namespace GoodCSharp { - public class GoodCSharpStackProps : StackProps + public class GoodCSharpProps : StackProps { } /// /// AWS CloudFormation Sample Template S3_Website_Bucket_With_Retain_On_Delete: Sample template showing how to create a publicly accessible S3 bucket configured for website access with a deletion policy of retain on delete. /// - public class GoodCSharpStack : Stack + public class GoodCSharp : Stack { /// /// URL for website hosted on S3 @@ -24,7 +24,7 @@ public class GoodCSharpStack : Stack /// public object S3BucketSecureURL { get; } - public GoodCSharpStack(Construct scope, string id, GoodCSharpStackProps props = null) : base(scope, id, props) + public GoodCSharp(Construct scope, string id, GoodCSharpProps props = null) : base(scope, id, props) { // Resources From 3144267c24149792d67a434f3d4b273160213a47 Mon Sep 17 00:00:00 2001 From: Hogan Bobertz Date: Tue, 26 Sep 2023 19:59:21 -0400 Subject: [PATCH 23/39] stackname and namespace should include stack --- packages/aws-cdk/lib/commands/migrate.ts | 2 +- .../app/csharp/src/%name.PascalCased%/Program.template.cs | 4 ++-- packages/aws-cdk/lib/init.ts | 4 ++-- packages/aws-cdk/test/commands/migrate.test.ts | 2 +- .../test/commands/test-resources/stacks/S3Stack.cs | 8 ++++---- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/aws-cdk/lib/commands/migrate.ts b/packages/aws-cdk/lib/commands/migrate.ts index 2cb7a9b3ee1aa..a1ca3248b9b35 100644 --- a/packages/aws-cdk/lib/commands/migrate.ts +++ b/packages/aws-cdk/lib/commands/migrate.ts @@ -79,7 +79,7 @@ export async function generateCdkApp(stackName: string, stack: string, language: */ export function generateStack(template: string, stackName: string, language: string) { try { - const formattedStackName = `${camelCase(decamelize(stackName), { pascalCase: true })}` + (language == 'csharp' ? '' : 'Stack'); + const formattedStackName = `${camelCase(decamelize(stackName), { pascalCase: true })}Stack`; return cdk_from_cfn.transmute(template, language, formattedStackName); } catch (e) { throw new Error(`stack generation failed due to error '${(e as Error).message}'`); diff --git a/packages/aws-cdk/lib/init-templates/app/csharp/src/%name.PascalCased%/Program.template.cs b/packages/aws-cdk/lib/init-templates/app/csharp/src/%name.PascalCased%/Program.template.cs index 917c0ae6f6139..0079f4418d1d0 100644 --- a/packages/aws-cdk/lib/init-templates/app/csharp/src/%name.PascalCased%/Program.template.cs +++ b/packages/aws-cdk/lib/init-templates/app/csharp/src/%name.PascalCased%/Program.template.cs @@ -3,14 +3,14 @@ using System.Collections.Generic; using System.Linq; -namespace %name.PascalCased% +namespace %PascalNameSpace% { sealed class Program { public static void Main(string[] args) { var app = new App(); - new %PascalStackName%(app, "%stackname%", new %PascalStackProps% + new %name.PascalCased%Stack(app, "%stackname%", new %PascalStackProps% { // If you don't specify 'env', this stack will be environment-agnostic. // Account/Region-dependent features and context lookups will not work, diff --git a/packages/aws-cdk/lib/init.ts b/packages/aws-cdk/lib/init.ts index c903695403e19..cbbcc940eae4f 100644 --- a/packages/aws-cdk/lib/init.ts +++ b/packages/aws-cdk/lib/init.ts @@ -173,8 +173,8 @@ export class InitTemplate { } return template.replace(/%name%/g, project.name) .replace(/%stackname%/, project.stackName ?? '%name.PascalCased%Stack') - .replace(/%PascalStackName%/, project.stackName ? camelCase(project.stackName, { pascalCase: true }) : '%name.PascalCased%Stack') - .replace(/%PascalStackProps%/, project.stackName ? (camelCase(project.stackName, { pascalCase: true }) + 'Props') : 'StackProps') + .replace(/%PascalNameSpace%/, project.stackName ? camelCase(project.stackName + 'Stack', { pascalCase: true }) : '%name.PascalCased%') + .replace(/%PascalStackProps%/, project.stackName ? (camelCase(project.stackName, { pascalCase: true }) + 'StackProps') : 'StackProps') .replace(/%name\.camelCased%/g, camelCase(project.name)) .replace(/%name\.PascalCased%/g, camelCase(project.name, { pascalCase: true })) .replace(/%cdk-version%/g, cdkVersion) diff --git a/packages/aws-cdk/test/commands/migrate.test.ts b/packages/aws-cdk/test/commands/migrate.test.ts index 1e17e7ac75800..fedaa7c128458 100644 --- a/packages/aws-cdk/test/commands/migrate.test.ts +++ b/packages/aws-cdk/test/commands/migrate.test.ts @@ -177,7 +177,7 @@ describe('Migrate Function Tests', () => { // Replaced stack file is referenced correctly in app file const app = fs.readFileSync(path.join(workDir, 'GoodCSharp', 'src', 'GoodCSharp', 'Program.cs'), 'utf8').split('\n'); expect(app.map(line => line.match('namespace GoodCSharp')).filter(line => line).length).toEqual(1); - expect(app.map(line => line.match(/ new GoodCSharp\(app, "GoodCSharp", new GoodCSharpProps/)).filter(line => line).length).toEqual(1); + expect(app.map(line => line.match(/ new GoodCSharpStack\(app, "GoodCSharp", new GoodCSharpStackProps/)).filter(line => line).length).toEqual(1); // Replaced stack file is correctly generated const replacedStack = fs.readFileSync(path.join(workDir, 'GoodCSharp', 'src', 'GoodCSharp', 'GoodCSharpStack.cs')); diff --git a/packages/aws-cdk/test/commands/test-resources/stacks/S3Stack.cs b/packages/aws-cdk/test/commands/test-resources/stacks/S3Stack.cs index 7204125037b2c..bc29e736d2482 100644 --- a/packages/aws-cdk/test/commands/test-resources/stacks/S3Stack.cs +++ b/packages/aws-cdk/test/commands/test-resources/stacks/S3Stack.cs @@ -3,16 +3,16 @@ using Constructs; using System.Collections.Generic; -namespace GoodCSharp +namespace GoodCSharpStack { - public class GoodCSharpProps : StackProps + public class GoodCSharpStackProps : StackProps { } /// /// AWS CloudFormation Sample Template S3_Website_Bucket_With_Retain_On_Delete: Sample template showing how to create a publicly accessible S3 bucket configured for website access with a deletion policy of retain on delete. /// - public class GoodCSharp : Stack + public class GoodCSharpStack : Stack { /// /// URL for website hosted on S3 @@ -24,7 +24,7 @@ public class GoodCSharp : Stack /// public object S3BucketSecureURL { get; } - public GoodCSharp(Construct scope, string id, GoodCSharpProps props = null) : base(scope, id, props) + public GoodCSharpStack(Construct scope, string id, GoodCSharpStackProps props = null) : base(scope, id, props) { // Resources From 0ebb6f462fed64a9fca7db80f8001106cceae497 Mon Sep 17 00:00:00 2001 From: Hogan Bobertz Date: Wed, 27 Sep 2023 10:02:34 -0400 Subject: [PATCH 24/39] update to 0.27.0 --- packages/@aws-cdk/cli-lib-alpha/THIRD_PARTY_LICENSES | 2 +- packages/aws-cdk/THIRD_PARTY_LICENSES | 2 +- packages/aws-cdk/package.json | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/@aws-cdk/cli-lib-alpha/THIRD_PARTY_LICENSES b/packages/@aws-cdk/cli-lib-alpha/THIRD_PARTY_LICENSES index b69cc62112f9b..389d67ba227b9 100644 --- a/packages/@aws-cdk/cli-lib-alpha/THIRD_PARTY_LICENSES +++ b/packages/@aws-cdk/cli-lib-alpha/THIRD_PARTY_LICENSES @@ -461,7 +461,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI ---------------- -** cdk-from-cfn@0.23.0 - https://www.npmjs.com/package/cdk-from-cfn/v/0.23.0 | MIT OR Apache-2.0 +** cdk-from-cfn@0.27.0 - https://www.npmjs.com/package/cdk-from-cfn/v/0.27.0 | MIT OR Apache-2.0 ---------------- diff --git a/packages/aws-cdk/THIRD_PARTY_LICENSES b/packages/aws-cdk/THIRD_PARTY_LICENSES index 8f42cbd123a57..6d642ff642364 100644 --- a/packages/aws-cdk/THIRD_PARTY_LICENSES +++ b/packages/aws-cdk/THIRD_PARTY_LICENSES @@ -461,7 +461,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI ---------------- -** cdk-from-cfn@0.23.0 - https://www.npmjs.com/package/cdk-from-cfn/v/0.23.0 | MIT OR Apache-2.0 +** cdk-from-cfn@0.27.0 - https://www.npmjs.com/package/cdk-from-cfn/v/0.27.0 | MIT OR Apache-2.0 ---------------- diff --git a/packages/aws-cdk/package.json b/packages/aws-cdk/package.json index e88fb17a66e94..d24c492b44c82 100644 --- a/packages/aws-cdk/package.json +++ b/packages/aws-cdk/package.json @@ -82,7 +82,7 @@ "aws-cdk-lib": "0.0.0", "aws-sdk-mock": "5.6.0", "axios": "^0.27.2", - "cdk-from-cfn": "^0.23.0", + "cdk-from-cfn": "^0.27.0", "constructs": "^10.0.0", "fast-check": "^3.13.0", "jest": "^29.7.0", @@ -105,7 +105,7 @@ "aws-sdk": "^2.1461.0", "camelcase": "^6.3.0", "cdk-assets": "0.0.0", - "cdk-from-cfn": "^0.23.0", + "cdk-from-cfn": "^0.27.0", "chalk": "^4", "chokidar": "^3.5.3", "decamelize": "^5.0.1", From b8d033b29975ecb168dc3ab9cbf0618f52fee5e1 Mon Sep 17 00:00:00 2001 From: Hogan Bobertz Date: Wed, 27 Sep 2023 10:25:03 -0400 Subject: [PATCH 25/39] add 0.27.0 to yarn lock --- yarn.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/yarn.lock b/yarn.lock index c887ea2b1819a..f7c160f4c98fc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5334,10 +5334,10 @@ case@1.6.3, case@^1.6.3: resolved "https://registry.npmjs.org/case/-/case-1.6.3.tgz#0a4386e3e9825351ca2e6216c60467ff5f1ea1c9" integrity sha512-mzDSXIPaFwVDvZAHqZ9VlbyF4yyXRuX6IvB06WvPYkqJVO24kX1PPhv9bfpKNFZyxYFmmgo03HUiD8iklmJYRQ== -cdk-from-cfn@^0.23.0: - version "0.23.0" - resolved "https://registry.npmjs.org/cdk-from-cfn/-/cdk-from-cfn-0.23.0.tgz#2f825955ff8d79c5ecd6cf17d8beb22535e50c96" - integrity sha512-JOcTlr1x9aBi3UrG2BOJcMVWeBIOq+zFS8YDtdog6znKPjaM7ixTM3XXFT/u9UEP4q7AikmiqUE85ocrkKHgOg== +cdk-from-cfn@^0.27.0: + version "0.27.0" + resolved "https://registry.npmjs.org/cdk-from-cfn/-/cdk-from-cfn-0.27.0.tgz#254a6220e69e2a84aff540315f73a8b297d33f59" + integrity sha512-YLaBRYi4PH1bO1HoMAO4QsP5WssankcQG9mkH1iwluziHi/Xdg19jc0qT1e63oB3Eb3nA/dcE/n/zZDkiwHSvA== cdk-generate-synthetic-examples@^0.1.291: version "0.1.291" From 31feecb6acd3ddc8e6e7ecd3be84917554aeb9b2 Mon Sep 17 00:00:00 2001 From: Kendra Neil <53584728+TheRealAmazonKendra@users.noreply.github.com> Date: Wed, 27 Sep 2023 19:51:14 -0700 Subject: [PATCH 26/39] Delete packages/@aws-cdk-testing/cli-integ/resources/templates/autoscaling-template.yml --- .../templates/autoscaling-template.yml | 677 ------------------ 1 file changed, 677 deletions(-) delete mode 100644 packages/@aws-cdk-testing/cli-integ/resources/templates/autoscaling-template.yml diff --git a/packages/@aws-cdk-testing/cli-integ/resources/templates/autoscaling-template.yml b/packages/@aws-cdk-testing/cli-integ/resources/templates/autoscaling-template.yml deleted file mode 100644 index 3178ee9558678..0000000000000 --- a/packages/@aws-cdk-testing/cli-integ/resources/templates/autoscaling-template.yml +++ /dev/null @@ -1,677 +0,0 @@ -AWSTemplateFormatVersion: 2010-09-09 -Description: >- - AWS CloudFormation Sample Template AutoScalingMultiAZWithNotifications: Create - a multi-az, load balanced and Auto Scaled sample web site running on an Apache - Web Serever. The application is configured to span all Availability Zones in - the region and is Auto-Scaled based on the CPU utilization of the web servers. - Notifications will be sent to the operator email address on scaling events. - The instances are load balanced with a simple health check against the default - web page. -Parameters: - VpcId: - Type: 'AWS::EC2::VPC::Id' - Description: VpcId of your existing Virtual Private Cloud (VPC) - ConstraintDescription: must be the VPC Id of an existing Virtual Private Cloud. - Subnets: - Type: 'List' - Description: The list of SubnetIds in your Virtual Private Cloud (VPC) - ConstraintDescription: >- - must be a list of at least two existing subnets associated with at least - two different availability zones. They should be residing in the selected - Virtual Private Cloud. - InstanceType: - Description: WebServer EC2 instance type - Type: String - Default: t2.small - AllowedValues: - - t1.micro - - t2.nano - - t2.micro - - t2.small - - t2.medium - - t2.large - - m1.small - - m1.medium - - m1.large - - m1.xlarge - - m2.xlarge - - m2.2xlarge - - m2.4xlarge - - m3.medium - - m3.large - - m3.xlarge - - m3.2xlarge - - m4.large - - m4.xlarge - - m4.2xlarge - - m4.4xlarge - - m4.10xlarge - - c1.medium - - c1.xlarge - - c3.large - - c3.xlarge - - c3.2xlarge - - c3.4xlarge - - c3.8xlarge - - c4.large - - c4.xlarge - - c4.2xlarge - - c4.4xlarge - - c4.8xlarge - - g2.2xlarge - - g2.8xlarge - - r3.large - - r3.xlarge - - r3.2xlarge - - r3.4xlarge - - r3.8xlarge - - i2.xlarge - - i2.2xlarge - - i2.4xlarge - - i2.8xlarge - - d2.xlarge - - d2.2xlarge - - d2.4xlarge - - d2.8xlarge - - hi1.4xlarge - - hs1.8xlarge - - cr1.8xlarge - - cc2.8xlarge - - cg1.4xlarge - ConstraintDescription: must be a valid EC2 instance type. - OperatorEMail: - Description: EMail address to notify if there are any scaling operations - Type: String - AllowedPattern: >- - ([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?) - ConstraintDescription: must be a valid email address. - KeyName: - Description: The EC2 Key Pair to allow SSH access to the instances - Type: 'AWS::EC2::KeyPair::KeyName' - ConstraintDescription: must be the name of an existing EC2 KeyPair. - SSHLocation: - Description: The IP address range that can be used to SSH to the EC2 instances - Type: String - MinLength: '9' - MaxLength: '18' - Default: 0.0.0.0/0 - AllowedPattern: '(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2})' - ConstraintDescription: must be a valid IP CIDR range of the form x.x.x.x/x. -Mappings: - Region2Examples: - ap-east-1: - Examples: 'https://s3-ap-east-1.amazonaws.com/cloudformation-examples-ap-east-1' - ap-northeast-1: - Examples: >- - https://s3-ap-northeast-1.amazonaws.com/cloudformation-examples-ap-northeast-1 - ap-northeast-2: - Examples: >- - https://s3-ap-northeast-2.amazonaws.com/cloudformation-examples-ap-northeast-2 - ap-northeast-3: - Examples: >- - https://s3-ap-northeast-3.amazonaws.com/cloudformation-examples-ap-northeast-3 - ap-south-1: - Examples: 'https://s3-ap-south-1.amazonaws.com/cloudformation-examples-ap-south-1' - ap-southeast-1: - Examples: >- - https://s3-ap-southeast-1.amazonaws.com/cloudformation-examples-ap-southeast-1 - ap-southeast-2: - Examples: >- - https://s3-ap-southeast-2.amazonaws.com/cloudformation-examples-ap-southeast-2 - ca-central-1: - Examples: >- - https://s3-ca-central-1.amazonaws.com/cloudformation-examples-ca-central-1 - cn-north-1: - Examples: >- - https://s3.cn-north-1.amazonaws.com.cn/cloudformation-examples-cn-north-1 - cn-northwest-1: - Examples: >- - https://s3.cn-northwest-1.amazonaws.com.cn/cloudformation-examples-cn-northwest-1 - eu-central-1: - Examples: >- - https://s3-eu-central-1.amazonaws.com/cloudformation-examples-eu-central-1 - eu-north-1: - Examples: 'https://s3-eu-north-1.amazonaws.com/cloudformation-examples-eu-north-1' - eu-west-1: - Examples: 'https://s3-eu-west-1.amazonaws.com/cloudformation-examples-eu-west-1' - eu-west-2: - Examples: 'https://s3-eu-west-2.amazonaws.com/cloudformation-examples-eu-west-2' - eu-west-3: - Examples: 'https://s3-eu-west-3.amazonaws.com/cloudformation-examples-eu-west-3' - me-south-1: - Examples: 'https://s3-me-south-1.amazonaws.com/cloudformation-examples-me-south-1' - sa-east-1: - Examples: 'https://s3-sa-east-1.amazonaws.com/cloudformation-examples-sa-east-1' - us-east-1: - Examples: 'https://s3.amazonaws.com/cloudformation-examples-us-east-1' - us-east-2: - Examples: 'https://s3-us-east-2.amazonaws.com/cloudformation-examples-us-east-2' - us-west-1: - Examples: 'https://s3-us-west-1.amazonaws.com/cloudformation-examples-us-west-1' - us-west-2: - Examples: 'https://s3-us-west-2.amazonaws.com/cloudformation-examples-us-west-2' - AWSInstanceType2Arch: - t1.micro: - Arch: HVM64 - t2.nano: - Arch: HVM64 - t2.micro: - Arch: HVM64 - t2.small: - Arch: HVM64 - t2.medium: - Arch: HVM64 - t2.large: - Arch: HVM64 - m1.small: - Arch: HVM64 - m1.medium: - Arch: HVM64 - m1.large: - Arch: HVM64 - m1.xlarge: - Arch: HVM64 - m2.xlarge: - Arch: HVM64 - m2.2xlarge: - Arch: HVM64 - m2.4xlarge: - Arch: HVM64 - m3.medium: - Arch: HVM64 - m3.large: - Arch: HVM64 - m3.xlarge: - Arch: HVM64 - m3.2xlarge: - Arch: HVM64 - m4.large: - Arch: HVM64 - m4.xlarge: - Arch: HVM64 - m4.2xlarge: - Arch: HVM64 - m4.4xlarge: - Arch: HVM64 - m4.10xlarge: - Arch: HVM64 - c1.medium: - Arch: HVM64 - c1.xlarge: - Arch: HVM64 - c3.large: - Arch: HVM64 - c3.xlarge: - Arch: HVM64 - c3.2xlarge: - Arch: HVM64 - c3.4xlarge: - Arch: HVM64 - c3.8xlarge: - Arch: HVM64 - c4.large: - Arch: HVM64 - c4.xlarge: - Arch: HVM64 - c4.2xlarge: - Arch: HVM64 - c4.4xlarge: - Arch: HVM64 - c4.8xlarge: - Arch: HVM64 - g2.2xlarge: - Arch: HVMG2 - g2.8xlarge: - Arch: HVMG2 - r3.large: - Arch: HVM64 - r3.xlarge: - Arch: HVM64 - r3.2xlarge: - Arch: HVM64 - r3.4xlarge: - Arch: HVM64 - r3.8xlarge: - Arch: HVM64 - i2.xlarge: - Arch: HVM64 - i2.2xlarge: - Arch: HVM64 - i2.4xlarge: - Arch: HVM64 - i2.8xlarge: - Arch: HVM64 - d2.xlarge: - Arch: HVM64 - d2.2xlarge: - Arch: HVM64 - d2.4xlarge: - Arch: HVM64 - d2.8xlarge: - Arch: HVM64 - hi1.4xlarge: - Arch: HVM64 - hs1.8xlarge: - Arch: HVM64 - cr1.8xlarge: - Arch: HVM64 - cc2.8xlarge: - Arch: HVM64 - AWSInstanceType2NATArch: - t1.micro: - Arch: NATHVM64 - t2.nano: - Arch: NATHVM64 - t2.micro: - Arch: NATHVM64 - t2.small: - Arch: NATHVM64 - t2.medium: - Arch: NATHVM64 - t2.large: - Arch: NATHVM64 - m1.small: - Arch: NATHVM64 - m1.medium: - Arch: NATHVM64 - m1.large: - Arch: NATHVM64 - m1.xlarge: - Arch: NATHVM64 - m2.xlarge: - Arch: NATHVM64 - m2.2xlarge: - Arch: NATHVM64 - m2.4xlarge: - Arch: NATHVM64 - m3.medium: - Arch: NATHVM64 - m3.large: - Arch: NATHVM64 - m3.xlarge: - Arch: NATHVM64 - m3.2xlarge: - Arch: NATHVM64 - m4.large: - Arch: NATHVM64 - m4.xlarge: - Arch: NATHVM64 - m4.2xlarge: - Arch: NATHVM64 - m4.4xlarge: - Arch: NATHVM64 - m4.10xlarge: - Arch: NATHVM64 - c1.medium: - Arch: NATHVM64 - c1.xlarge: - Arch: NATHVM64 - c3.large: - Arch: NATHVM64 - c3.xlarge: - Arch: NATHVM64 - c3.2xlarge: - Arch: NATHVM64 - c3.4xlarge: - Arch: NATHVM64 - c3.8xlarge: - Arch: NATHVM64 - c4.large: - Arch: NATHVM64 - c4.xlarge: - Arch: NATHVM64 - c4.2xlarge: - Arch: NATHVM64 - c4.4xlarge: - Arch: NATHVM64 - c4.8xlarge: - Arch: NATHVM64 - g2.2xlarge: - Arch: NATHVMG2 - g2.8xlarge: - Arch: NATHVMG2 - r3.large: - Arch: NATHVM64 - r3.xlarge: - Arch: NATHVM64 - r3.2xlarge: - Arch: NATHVM64 - r3.4xlarge: - Arch: NATHVM64 - r3.8xlarge: - Arch: NATHVM64 - i2.xlarge: - Arch: NATHVM64 - i2.2xlarge: - Arch: NATHVM64 - i2.4xlarge: - Arch: NATHVM64 - i2.8xlarge: - Arch: NATHVM64 - d2.xlarge: - Arch: NATHVM64 - d2.2xlarge: - Arch: NATHVM64 - d2.4xlarge: - Arch: NATHVM64 - d2.8xlarge: - Arch: NATHVM64 - hi1.4xlarge: - Arch: NATHVM64 - hs1.8xlarge: - Arch: NATHVM64 - cr1.8xlarge: - Arch: NATHVM64 - cc2.8xlarge: - Arch: NATHVM64 - AWSRegionArch2AMI: - af-south-1: - HVM64: ami-064cc455f8a1ef504 - HVMG2: NOT_SUPPORTED - ap-east-1: - HVM64: ami-f85b1989 - HVMG2: NOT_SUPPORTED - ap-northeast-1: - HVM64: ami-0b2c2a754d5b4da22 - HVMG2: ami-09d0e0e099ecabba2 - ap-northeast-2: - HVM64: ami-0493ab99920f410fc - HVMG2: NOT_SUPPORTED - ap-northeast-3: - HVM64: ami-01344f6f63a4decc1 - HVMG2: NOT_SUPPORTED - ap-south-1: - HVM64: ami-03cfb5e1fb4fac428 - HVMG2: ami-0244c1d42815af84a - ap-southeast-1: - HVM64: ami-0ba35dc9caf73d1c7 - HVMG2: ami-0e46ce0d6a87dc979 - ap-southeast-2: - HVM64: ami-0ae99b503e8694028 - HVMG2: ami-0c0ab057a101d8ff2 - ca-central-1: - HVM64: ami-0803e21a2ec22f953 - HVMG2: NOT_SUPPORTED - cn-north-1: - HVM64: ami-07a3f215cc90c889c - HVMG2: NOT_SUPPORTED - cn-northwest-1: - HVM64: ami-0a3b3b10f714a0ff4 - HVMG2: NOT_SUPPORTED - eu-central-1: - HVM64: ami-0474863011a7d1541 - HVMG2: ami-0aa1822e3eb913a11 - eu-north-1: - HVM64: ami-0de4b8910494dba0f - HVMG2: ami-32d55b4c - eu-south-1: - HVM64: ami-08427144fe9ebdef6 - HVMG2: NOT_SUPPORTED - eu-west-1: - HVM64: ami-015232c01a82b847b - HVMG2: ami-0d5299b1c6112c3c7 - eu-west-2: - HVM64: ami-0765d48d7e15beb93 - HVMG2: NOT_SUPPORTED - eu-west-3: - HVM64: ami-0caf07637eda19d9c - HVMG2: NOT_SUPPORTED - me-south-1: - HVM64: ami-0744743d80915b497 - HVMG2: NOT_SUPPORTED - sa-east-1: - HVM64: ami-0a52e8a6018e92bb0 - HVMG2: NOT_SUPPORTED - us-east-1: - HVM64: ami-032930428bf1abbff - HVMG2: ami-0aeb704d503081ea6 - us-east-2: - HVM64: ami-027cab9a7bf0155df - HVMG2: NOT_SUPPORTED - us-west-1: - HVM64: ami-088c153f74339f34c - HVMG2: ami-0a7fc72dc0e51aa77 - us-west-2: - HVM64: ami-01fee56b22f308154 - HVMG2: ami-0fe84a5b4563d8f27 -Resources: - NotificationTopic: - Type: 'AWS::SNS::Topic' - Properties: - Subscription: - - Endpoint: !Ref OperatorEMail - Protocol: email - WebServerGroup: - Type: 'AWS::AutoScaling::AutoScalingGroup' - Properties: - VPCZoneIdentifier: !Ref Subnets - LaunchConfigurationName: !Ref LaunchConfig - MinSize: '1' - MaxSize: '3' - TargetGroupARNs: - - !Ref ALBTargetGroup - NotificationConfiguration: - TopicARN: !Ref NotificationTopic - NotificationTypes: - - 'autoscaling:EC2_INSTANCE_LAUNCH' - - 'autoscaling:EC2_INSTANCE_LAUNCH_ERROR' - - 'autoscaling:EC2_INSTANCE_TERMINATE' - - 'autoscaling:EC2_INSTANCE_TERMINATE_ERROR' - CreationPolicy: - ResourceSignal: - Timeout: PT15M - Count: '1' - UpdatePolicy: - AutoScalingRollingUpdate: - MinInstancesInService: '1' - MaxBatchSize: '1' - PauseTime: PT15M - WaitOnResourceSignals: 'true' - LaunchConfig: - Type: 'AWS::AutoScaling::LaunchConfiguration' - Metadata: - Comment: Install a simple application - 'AWS::CloudFormation::Init': - config: - packages: - yum: - httpd: [] - files: - /var/www/html/index.html: - content: !Join - - |+ - - - - AWS CloudFormation Logo - - >- -

Congratulations, you have successfully launched the AWS - CloudFormation sample.

- mode: '000644' - owner: root - group: root - /etc/cfn/cfn-hup.conf: - content: !Join - - '' - - - | - [main] - - stack= - - !Ref 'AWS::StackId' - - |+ - - - region= - - !Ref 'AWS::Region' - - |+ - - mode: '000400' - owner: root - group: root - /etc/cfn/hooks.d/cfn-auto-reloader.conf: - content: !Join - - '' - - - | - [cfn-auto-reloader-hook] - - | - triggers=post.update - - > - path=Resources.LaunchConfig.Metadata.AWS::CloudFormation::Init - - 'action=/opt/aws/bin/cfn-init -v ' - - ' --stack ' - - !Ref 'AWS::StackName' - - ' --resource LaunchConfig ' - - ' --region ' - - !Ref 'AWS::Region' - - |+ - - - | - runas=root - mode: '000400' - owner: root - group: root - services: - sysvinit: - httpd: - enabled: 'true' - ensureRunning: 'true' - cfn-hup: - enabled: 'true' - ensureRunning: 'true' - files: - - /etc/cfn/cfn-hup.conf - - /etc/cfn/hooks.d/cfn-auto-reloader.conf - Properties: - KeyName: !Ref KeyName - ImageId: !FindInMap - - AWSRegionArch2AMI - - !Ref 'AWS::Region' - - !FindInMap - - AWSInstanceType2Arch - - !Ref InstanceType - - Arch - SecurityGroups: - - !Ref InstanceSecurityGroup - InstanceType: !Ref InstanceType - UserData: !Base64 - 'Fn::Join': - - '' - - - | - #!/bin/bash -xe - - | - yum update -y aws-cfn-bootstrap - - | - yum update -y aws-cli - - '/opt/aws/bin/cfn-init -v ' - - ' --stack ' - - !Ref 'AWS::StackName' - - ' --resource LaunchConfig ' - - ' --region ' - - !Ref 'AWS::Region' - - |+ - - - '/opt/aws/bin/cfn-signal -e $? ' - - ' --stack ' - - !Ref 'AWS::StackName' - - ' --resource WebServerGroup ' - - ' --region ' - - !Ref 'AWS::Region' - - |+ - - WebServerScaleUpPolicy: - Type: 'AWS::AutoScaling::ScalingPolicy' - Properties: - AdjustmentType: ChangeInCapacity - AutoScalingGroupName: !Ref WebServerGroup - Cooldown: '60' - ScalingAdjustment: '1' - WebServerScaleDownPolicy: - Type: 'AWS::AutoScaling::ScalingPolicy' - Properties: - AdjustmentType: ChangeInCapacity - AutoScalingGroupName: !Ref WebServerGroup - Cooldown: '60' - ScalingAdjustment: '-1' - CPUAlarmHigh: - Type: 'AWS::CloudWatch::Alarm' - Properties: - AlarmDescription: Scale-up if CPU > 90% for 10 minutes - MetricName: CPUUtilization - Namespace: AWS/EC2 - Statistic: Average - Period: '300' - EvaluationPeriods: '2' - Threshold: '90' - AlarmActions: - - !Ref WebServerScaleUpPolicy - Dimensions: - - Name: AutoScalingGroupName - Value: !Ref WebServerGroup - ComparisonOperator: GreaterThanThreshold - CPUAlarmLow: - Type: 'AWS::CloudWatch::Alarm' - Properties: - AlarmDescription: Scale-down if CPU < 70% for 10 minutes - MetricName: CPUUtilization - Namespace: AWS/EC2 - Statistic: Average - Period: '300' - EvaluationPeriods: '2' - Threshold: '70' - AlarmActions: - - !Ref WebServerScaleDownPolicy - Dimensions: - - Name: AutoScalingGroupName - Value: !Ref WebServerGroup - ComparisonOperator: LessThanThreshold - ApplicationLoadBalancer: - Type: 'AWS::ElasticLoadBalancingV2::LoadBalancer' - Properties: - Subnets: !Ref Subnets - ALBListener: - Type: 'AWS::ElasticLoadBalancingV2::Listener' - Properties: - DefaultActions: - - Type: forward - TargetGroupArn: !Ref ALBTargetGroup - LoadBalancerArn: !Ref ApplicationLoadBalancer - Port: '80' - Protocol: HTTP - ALBTargetGroup: - Type: 'AWS::ElasticLoadBalancingV2::TargetGroup' - Properties: - HealthCheckIntervalSeconds: 30 - HealthCheckTimeoutSeconds: 5 - HealthyThresholdCount: 3 - Port: 80 - Protocol: HTTP - UnhealthyThresholdCount: 5 - VpcId: !Ref VpcId - InstanceSecurityGroup: - Type: 'AWS::EC2::SecurityGroup' - Properties: - GroupDescription: Enable SSH access and HTTP from the load balancer only - SecurityGroupIngress: - - IpProtocol: tcp - FromPort: '22' - ToPort: '22' - CidrIp: !Ref SSHLocation - - IpProtocol: tcp - FromPort: '80' - ToPort: '80' - SourceSecurityGroupId: !Select - - 0 - - !GetAtt - - ApplicationLoadBalancer - - SecurityGroups - VpcId: !Ref VpcId -Outputs: - URL: - Description: The URL of the website - Value: !Join - - '' - - - 'http://' - - !GetAtt - - ApplicationLoadBalancer - - DNSName \ No newline at end of file From d4d4dcce24c84192546cc47483f3c4b7bf713980 Mon Sep 17 00:00:00 2001 From: Kendra Neil <53584728+TheRealAmazonKendra@users.noreply.github.com> Date: Wed, 27 Sep 2023 19:51:24 -0700 Subject: [PATCH 27/39] Delete packages/@aws-cdk-testing/cli-integ/resources/templates/simpleDDB.yaml --- .../resources/templates/simpleDDB.yaml | 79 ------------------- 1 file changed, 79 deletions(-) delete mode 100644 packages/@aws-cdk-testing/cli-integ/resources/templates/simpleDDB.yaml diff --git a/packages/@aws-cdk-testing/cli-integ/resources/templates/simpleDDB.yaml b/packages/@aws-cdk-testing/cli-integ/resources/templates/simpleDDB.yaml deleted file mode 100644 index f7a320b33dfa4..0000000000000 --- a/packages/@aws-cdk-testing/cli-integ/resources/templates/simpleDDB.yaml +++ /dev/null @@ -1,79 +0,0 @@ -AWSTemplateFormatVersion: "2010-09-09" -Resources: - myDynamoDBTable: - Type: AWS::DynamoDB::Table - Properties: - AttributeDefinitions: - - - AttributeName: "Album" - AttributeType: "S" - - - AttributeName: "Artist" - AttributeType: "S" - - - AttributeName: "Sales" - AttributeType: "N" - - - AttributeName: "NumberOfSongs" - AttributeType: "N" - KeySchema: - - - AttributeName: "Album" - KeyType: "HASH" - - - AttributeName: "Artist" - KeyType: "RANGE" - ProvisionedThroughput: - ReadCapacityUnits: "5" - WriteCapacityUnits: "5" - TableName: "myTableName" - GlobalSecondaryIndexes: - - - IndexName: "myGSI" - KeySchema: - - - AttributeName: "Sales" - KeyType: "HASH" - - - AttributeName: "Artist" - KeyType: "RANGE" - Projection: - NonKeyAttributes: - - "Album" - - "NumberOfSongs" - ProjectionType: "INCLUDE" - ProvisionedThroughput: - ReadCapacityUnits: "5" - WriteCapacityUnits: "5" - - - IndexName: "myGSI2" - KeySchema: - - - AttributeName: "NumberOfSongs" - KeyType: "HASH" - - - AttributeName: "Sales" - KeyType: "RANGE" - Projection: - NonKeyAttributes: - - "Album" - - "Artist" - ProjectionType: "INCLUDE" - ProvisionedThroughput: - ReadCapacityUnits: "5" - WriteCapacityUnits: "5" - LocalSecondaryIndexes: - - - IndexName: "myLSI" - KeySchema: - - - AttributeName: "Album" - KeyType: "HASH" - - - AttributeName: "Sales" - KeyType: "RANGE" - Projection: - NonKeyAttributes: - - "Artist" - - "NumberOfSongs" - ProjectionType: "INCLUDE" \ No newline at end of file From 3dea05a5ff5266324d272bea1b56954d07cfc0c2 Mon Sep 17 00:00:00 2001 From: Kendra Neil <53584728+TheRealAmazonKendra@users.noreply.github.com> Date: Thu, 5 Oct 2023 16:36:33 -0700 Subject: [PATCH 28/39] python needs to install requirements --- .../cli-integ/tests/cli-integ-tests/cli.integtest.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts index cd8167d098b7a..c974583e80616 100644 --- a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts +++ b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts @@ -571,7 +571,8 @@ integTest('deploy with role', withDefaultFixture(async (fixture) => { } })); -['typescript', 'python', 'csharp', 'java', 'go'].forEach(langChoice => { +// TODO add go back in when template synths properly +['typescript', 'python', 'csharp', 'java'].forEach(langChoice => { integTest( `cdk migrate ${langChoice}`, withDefaultFixture(async (fixture) => { @@ -598,8 +599,13 @@ integTest('deploy with role', withDefaultFixture(async (fixture) => { fixture.output, fixture.aws, fixture.randomString); - if (langChoice == 'go') { + if (langChoice === 'go') { await tempFixture.shell(['go', 'get']); + } else if (langChoice === 'python') { + const venvPath = path.resolve(fixture.integTestDir, '.venv'); + const venv = { PATH: `${venvPath}/bin:${process.env.PATH}`, VIRTUAL_ENV: venvPath }; + + await tempFixture.shell([`${venvPath}/bin/pip`, 'install', '-r', 'requirements.txt'], { modEnv: venv }); } // go stack doesn't follow the same naming scheme as other languages. let stackArn; @@ -608,6 +614,7 @@ integTest('deploy with role', withDefaultFixture(async (fixture) => { } else { stackArn = await tempFixture.cdkDeploy(`${langChoice}-migrate-stack`, { captureStderr: false }); } + const response = await tempFixture.aws.cloudFormation('describeStacks', { StackName: stackArn, }); From ad6daea2740a92648d0d1335dc88a8a0badf4491 Mon Sep 17 00:00:00 2001 From: Kendra Neil <53584728+TheRealAmazonKendra@users.noreply.github.com> Date: Mon, 9 Oct 2023 12:22:07 -0700 Subject: [PATCH 29/39] make cli available --- .../cli-integ/tests/cli-integ-tests/cli.integtest.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts index c974583e80616..9da42d00ab590 100644 --- a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts +++ b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts @@ -602,6 +602,7 @@ integTest('deploy with role', withDefaultFixture(async (fixture) => { if (langChoice === 'go') { await tempFixture.shell(['go', 'get']); } else if (langChoice === 'python') { + await fixture.packages.makeCliAvailable(); const venvPath = path.resolve(fixture.integTestDir, '.venv'); const venv = { PATH: `${venvPath}/bin:${process.env.PATH}`, VIRTUAL_ENV: venvPath }; From cd74b8afdf64d8c570737fb352896e095db9ebf5 Mon Sep 17 00:00:00 2001 From: Kendra Neil <53584728+TheRealAmazonKendra@users.noreply.github.com> Date: Mon, 9 Oct 2023 14:40:42 -0700 Subject: [PATCH 30/39] only use one fixture --- .../tests/cli-integ-tests/cli.integtest.ts | 36 ++++++------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts index 9da42d00ab590..ff69ae7ae5510 100644 --- a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts +++ b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts @@ -1,7 +1,7 @@ import { promises as fs, existsSync } from 'fs'; import * as os from 'os'; import * as path from 'path'; -import { integTest, cloneDirectory, shell, withDefaultFixture, retry, sleep, randomInteger, withSamIntegrationFixture, RESOURCES_DIR, TestFixture } from '../../lib'; +import { integTest, cloneDirectory, shell, withDefaultFixture, retry, sleep, randomInteger, withSamIntegrationFixture, RESOURCES_DIR, TestFixture, withTemporaryDirectory, withPackages, ShellHelper } from '../../lib'; jest.setTimeout(2 * 60 * 60_000); // Includes the time to acquire locks, worst-case single-threaded runtime @@ -576,51 +576,37 @@ integTest('deploy with role', withDefaultFixture(async (fixture) => { integTest( `cdk migrate ${langChoice}`, withDefaultFixture(async (fixture) => { - const tempPath = path.join(fixture.integTestDir); - const inputFile = path.join(__dirname, '../../resources/templates/', 'sqs-template.json'); const stackName = fixture.stackNamePrefix + `-${langChoice}-migrate-stack`; await fixture.cdk([ 'migrate', '--language', - `${langChoice}`, + langChoice, '--stack-name', stackName, '--from-path', inputFile.toString(), - '--output-path', - tempPath.toString(), ]); - // Create a new fixture for the migrated app directory - const tempFixture = new TestFixture( - path.join(tempPath.toString(), stackName), - fixture.stackNamePrefix, - fixture.output, - fixture.aws, - fixture.randomString); + + await fixture.shell(['cd', stackName]); if (langChoice === 'go') { - await tempFixture.shell(['go', 'get']); + await fixture.shell(['go', 'get']); } else if (langChoice === 'python') { await fixture.packages.makeCliAvailable(); const venvPath = path.resolve(fixture.integTestDir, '.venv'); const venv = { PATH: `${venvPath}/bin:${process.env.PATH}`, VIRTUAL_ENV: venvPath }; - - await tempFixture.shell([`${venvPath}/bin/pip`, 'install', '-r', 'requirements.txt'], { modEnv: venv }); + await fixture.shell([`${venvPath}/bin/pip`, 'install', '-r', 'requirements.txt'], { modEnv: venv }); + await fixture.cdkSynth({ modEnv: venv }); } // go stack doesn't follow the same naming scheme as other languages. - let stackArn; - if (langChoice == 'go') { - stackArn = await tempFixture.cdk(['deploy', '--require-approval', 'never'], { captureStderr: false }); - } else { - stackArn = await tempFixture.cdkDeploy(`${langChoice}-migrate-stack`, { captureStderr: false }); - } - - const response = await tempFixture.aws.cloudFormation('describeStacks', { + const stackArn = await fixture.cdk(['deploy', '--require-approval', 'never'], { captureStderr: false }); + const response = await fixture.aws.cloudFormation('describeStacks', { StackName: stackArn, }); + expect(response.Stacks?.[0].StackStatus).toEqual('CREATE_COMPLETE'); - await tempFixture.cdkDestroy(`${langChoice}-migrate-stack`); + await fixture.cdkDestroy(`${langChoice}-migrate-stack`); }), ); }); From 0e8bdb1612a446b1b98bee5a428a64c8a9a8af7e Mon Sep 17 00:00:00 2001 From: Kendra Neil <53584728+TheRealAmazonKendra@users.noreply.github.com> Date: Mon, 9 Oct 2023 14:55:26 -0700 Subject: [PATCH 31/39] remove imports --- .../cli-integ/tests/cli-integ-tests/cli.integtest.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts index ff69ae7ae5510..b0f12d9617f7e 100644 --- a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts +++ b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts @@ -1,7 +1,7 @@ import { promises as fs, existsSync } from 'fs'; import * as os from 'os'; import * as path from 'path'; -import { integTest, cloneDirectory, shell, withDefaultFixture, retry, sleep, randomInteger, withSamIntegrationFixture, RESOURCES_DIR, TestFixture, withTemporaryDirectory, withPackages, ShellHelper } from '../../lib'; +import { integTest, cloneDirectory, shell, withDefaultFixture, retry, sleep, randomInteger, withSamIntegrationFixture, RESOURCES_DIR } from '../../lib'; jest.setTimeout(2 * 60 * 60_000); // Includes the time to acquire locks, worst-case single-threaded runtime From fef88d655bc00786401adbf02fb2b465e9388d7d Mon Sep 17 00:00:00 2001 From: Kendra Neil <53584728+TheRealAmazonKendra@users.noreply.github.com> Date: Mon, 9 Oct 2023 16:37:12 -0700 Subject: [PATCH 32/39] use codebuild pip instead of venv --- .../cli-integ/tests/cli-integ-tests/cli.integtest.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts index b0f12d9617f7e..e3964d2f3e5bb 100644 --- a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts +++ b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts @@ -594,10 +594,7 @@ integTest('deploy with role', withDefaultFixture(async (fixture) => { await fixture.shell(['go', 'get']); } else if (langChoice === 'python') { await fixture.packages.makeCliAvailable(); - const venvPath = path.resolve(fixture.integTestDir, '.venv'); - const venv = { PATH: `${venvPath}/bin:${process.env.PATH}`, VIRTUAL_ENV: venvPath }; - await fixture.shell([`${venvPath}/bin/pip`, 'install', '-r', 'requirements.txt'], { modEnv: venv }); - await fixture.cdkSynth({ modEnv: venv }); + await fixture.shell(['pip', 'install', '-r', 'requirements.txt']); } // go stack doesn't follow the same naming scheme as other languages. const stackArn = await fixture.cdk(['deploy', '--require-approval', 'never'], { captureStderr: false }); From 474713c76d1c2a03e699df15f2adfae130c2d08e Mon Sep 17 00:00:00 2001 From: Kendra Neil <53584728+TheRealAmazonKendra@users.noreply.github.com> Date: Mon, 9 Oct 2023 19:59:46 -0700 Subject: [PATCH 33/39] just troubleshooting --- .../cli-integ/tests/cli-integ-tests/cli.integtest.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts index e3964d2f3e5bb..fe2654f61956d 100644 --- a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts +++ b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts @@ -590,14 +590,16 @@ integTest('deploy with role', withDefaultFixture(async (fixture) => { ]); await fixture.shell(['cd', stackName]); + await fixture.shell(['ls']); + await fixture.shell(['pwd']); if (langChoice === 'go') { await fixture.shell(['go', 'get']); } else if (langChoice === 'python') { await fixture.packages.makeCliAvailable(); - await fixture.shell(['pip', 'install', '-r', 'requirements.txt']); + await fixture.shell(['pip3', 'install', '-r', 'requirements.txt']); } // go stack doesn't follow the same naming scheme as other languages. - const stackArn = await fixture.cdk(['deploy', '--require-approval', 'never'], { captureStderr: false }); + const stackArn = await fixture.cdk(['deploy', '--require-approval', 'never'], { captureStderr: false, verbose: true }); const response = await fixture.aws.cloudFormation('describeStacks', { StackName: stackArn, }); From 5ac289a9c49c646914476f83fa901b9598bd8b08 Mon Sep 17 00:00:00 2001 From: Kendra Neil <53584728+TheRealAmazonKendra@users.noreply.github.com> Date: Tue, 10 Oct 2023 14:17:43 -0700 Subject: [PATCH 34/39] more troubleshooting --- .../cli-integ/lib/with-cdk-app.ts | 53 +++++++++++++++++ .../tests/cli-integ-tests/cli.integtest.ts | 58 +++++++------------ 2 files changed, 75 insertions(+), 36 deletions(-) diff --git a/packages/@aws-cdk-testing/cli-integ/lib/with-cdk-app.ts b/packages/@aws-cdk-testing/cli-integ/lib/with-cdk-app.ts index a37edcb206dd4..459a1380f1361 100644 --- a/packages/@aws-cdk-testing/cli-integ/lib/with-cdk-app.ts +++ b/packages/@aws-cdk-testing/cli-integ/lib/with-cdk-app.ts @@ -84,6 +84,40 @@ export function withCdkApp( }; } +export function withCdkMigrateApp(language: string, block: (context: TestFixture) => Promise) { + return async (context: A) => { + const stackName = `cdk-migrate-${language}-integ-${context.randomString}`; + const integTestDir = path.join(os.tmpdir(), `cdk-migrate-${language}-integ-${context.randomString}`); + + context.output.write(` Stack name: ${stackName}\n`); + context.output.write(` Test directory: ${integTestDir}\n`); + + const awsClients = await AwsClients.default(context.output); + fs.mkdirSync(integTestDir); + const fixture = new TestFixture( + integTestDir, + stackName, + context.output, + awsClients, + context.randomString, + ); + + let success = true; + try { + await block(fixture); + } catch (e) { + success = false; + throw e; + } finally { + if (process.env.INTEG_NO_CLEAN) { + context.log(`Left test directory in '${integTestDir}' ($INTEG_NO_CLEAN)`); + } else { + await fixture.dispose(success); + } + } + }; +} + export function withMonolithicCfnIncludeCdkApp(block: (context: TestFixture) => Promise) { return async (context: A) => { const uberPackage = process.env.UBERPACKAGE; @@ -141,6 +175,10 @@ export function withDefaultFixture(block: (context: TestFixture) => Promise Promise) { + return withAws(withTimeout(DEFAULT_TEST_TIMEOUT_S, withCdkMigrateApp(language, block))); +} + export interface DisableBootstrapContext { /** * Whether to disable creating the default bootstrap @@ -379,6 +417,21 @@ export class TestFixture extends ShellHelper { }); } + public async cdkMigrate(language: string, stackName: string, inputPath?: string, options?: CdkCliOptions) { + inputPath ?? path.join(__dirname, 'resources', 'templates', 'sqs-template.json').toString(); + + return this.cdk([ + 'migrate', + '--language', + language, + '--stack-name', + stackName, + '--from-path', + inputPath!, + ...(options?.options ?? []), + ], options); + } + public async cdk(args: string[], options: CdkCliOptions = {}) { const verbose = options.verbose ?? true; diff --git a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts index fe2654f61956d..6a99569b84332 100644 --- a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts +++ b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts @@ -1,7 +1,7 @@ import { promises as fs, existsSync } from 'fs'; import * as os from 'os'; import * as path from 'path'; -import { integTest, cloneDirectory, shell, withDefaultFixture, retry, sleep, randomInteger, withSamIntegrationFixture, RESOURCES_DIR } from '../../lib'; +import { integTest, cloneDirectory, shell, withDefaultFixture, retry, sleep, randomInteger, withSamIntegrationFixture, RESOURCES_DIR, withCDKMigrateFixture } from '../../lib'; jest.setTimeout(2 * 60 * 60_000); // Includes the time to acquire locks, worst-case single-threaded runtime @@ -572,42 +572,28 @@ integTest('deploy with role', withDefaultFixture(async (fixture) => { })); // TODO add go back in when template synths properly -['typescript', 'python', 'csharp', 'java'].forEach(langChoice => { - integTest( - `cdk migrate ${langChoice}`, - withDefaultFixture(async (fixture) => { - const inputFile = path.join(__dirname, '../../resources/templates/', 'sqs-template.json'); - const stackName = fixture.stackNamePrefix + `-${langChoice}-migrate-stack`; - - await fixture.cdk([ - 'migrate', - '--language', - langChoice, - '--stack-name', - stackName, - '--from-path', - inputFile.toString(), - ]); - - await fixture.shell(['cd', stackName]); - await fixture.shell(['ls']); - await fixture.shell(['pwd']); - if (langChoice === 'go') { - await fixture.shell(['go', 'get']); - } else if (langChoice === 'python') { - await fixture.packages.makeCliAvailable(); - await fixture.shell(['pip3', 'install', '-r', 'requirements.txt']); - } - // go stack doesn't follow the same naming scheme as other languages. - const stackArn = await fixture.cdk(['deploy', '--require-approval', 'never'], { captureStderr: false, verbose: true }); - const response = await fixture.aws.cloudFormation('describeStacks', { - StackName: stackArn, - }); +['typescript', 'python', 'csharp', 'java'].forEach(language => { + withCDKMigrateFixture(language, async (fixture) => { + await fixture.cdkMigrate(language, fixture.stackNamePrefix); + await fixture.shell(['ls']); + await fixture.shell(['pwd']); + await fixture.shell(['cd', fixture.stackNamePrefix]); + await fixture.shell(['ls']); + await fixture.shell(['pwd']); + + if (language === 'python') { + await fixture.shell(['pip', 'install', '-r', 'requirements.txt']); + } - expect(response.Stacks?.[0].StackStatus).toEqual('CREATE_COMPLETE'); - await fixture.cdkDestroy(`${langChoice}-migrate-stack`); - }), - ); + const stackArn = await fixture.cdkDeploy(fixture.stackNamePrefix, { neverRequireApproval: true, verbose: true, captureStderr: false }); + const response = await fixture.aws.cloudFormation('describeStacks', { + StackName: stackArn, + }); + + expect(response.Stacks?.[0].StackStatus).toEqual('CREATE_COMPLETE'); + await fixture.cdkDestroy(fixture.stackNamePrefix); + + }); }); integTest('cdk diff', withDefaultFixture(async (fixture) => { From bdaaffb3a31be21fcd370fefbf3b996509aa922d Mon Sep 17 00:00:00 2001 From: Kendra Neil <53584728+TheRealAmazonKendra@users.noreply.github.com> Date: Tue, 10 Oct 2023 15:55:30 -0700 Subject: [PATCH 35/39] fix test --- .../cli-integ/tests/cli-integ-tests/cli.integtest.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts index 6a99569b84332..bdff36822cbaa 100644 --- a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts +++ b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts @@ -573,7 +573,7 @@ integTest('deploy with role', withDefaultFixture(async (fixture) => { // TODO add go back in when template synths properly ['typescript', 'python', 'csharp', 'java'].forEach(language => { - withCDKMigrateFixture(language, async (fixture) => { + integTest(`cdk migrate ${language}`, withCDKMigrateFixture(language, async (fixture) => { await fixture.cdkMigrate(language, fixture.stackNamePrefix); await fixture.shell(['ls']); await fixture.shell(['pwd']); @@ -592,8 +592,7 @@ integTest('deploy with role', withDefaultFixture(async (fixture) => { expect(response.Stacks?.[0].StackStatus).toEqual('CREATE_COMPLETE'); await fixture.cdkDestroy(fixture.stackNamePrefix); - - }); + })); }); integTest('cdk diff', withDefaultFixture(async (fixture) => { From b13a0804523920c064d3008fdd52c9953933887e Mon Sep 17 00:00:00 2001 From: Kendra Neil <53584728+TheRealAmazonKendra@users.noreply.github.com> Date: Tue, 10 Oct 2023 17:47:43 -0700 Subject: [PATCH 36/39] fix path --- packages/@aws-cdk-testing/cli-integ/lib/with-cdk-app.ts | 5 ++--- .../cli-integ/resources/integ.jest.config.js | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/@aws-cdk-testing/cli-integ/lib/with-cdk-app.ts b/packages/@aws-cdk-testing/cli-integ/lib/with-cdk-app.ts index 459a1380f1361..1c8f277e44efb 100644 --- a/packages/@aws-cdk-testing/cli-integ/lib/with-cdk-app.ts +++ b/packages/@aws-cdk-testing/cli-integ/lib/with-cdk-app.ts @@ -418,8 +418,7 @@ export class TestFixture extends ShellHelper { } public async cdkMigrate(language: string, stackName: string, inputPath?: string, options?: CdkCliOptions) { - inputPath ?? path.join(__dirname, 'resources', 'templates', 'sqs-template.json').toString(); - + console.log(path.join(__dirname, 'resources', 'templates', 'sqs-template.json').toString()); return this.cdk([ 'migrate', '--language', @@ -427,7 +426,7 @@ export class TestFixture extends ShellHelper { '--stack-name', stackName, '--from-path', - inputPath!, + inputPath ?? path.join(__dirname, 'resources', 'templates', 'sqs-template.json').toString(), ...(options?.options ?? []), ], options); } diff --git a/packages/@aws-cdk-testing/cli-integ/resources/integ.jest.config.js b/packages/@aws-cdk-testing/cli-integ/resources/integ.jest.config.js index e72d95ff70da6..06ad36ecb54c8 100644 --- a/packages/@aws-cdk-testing/cli-integ/resources/integ.jest.config.js +++ b/packages/@aws-cdk-testing/cli-integ/resources/integ.jest.config.js @@ -17,7 +17,7 @@ module.exports = { testTimeout: 300000, // Affects test.concurrent(), these are self-limiting anyway - maxConcurrency: 10, + maxWorkers: '50%', reporters: [ "default", [ "jest-junit", { suiteName: "jest tests", outputDirectory: "coverage" } ] From 0c6770d078cc17f8e8be4757eec929afdb1d449f Mon Sep 17 00:00:00 2001 From: Kendra Neil <53584728+TheRealAmazonKendra@users.noreply.github.com> Date: Tue, 10 Oct 2023 20:01:53 -0700 Subject: [PATCH 37/39] wrong path --- packages/@aws-cdk-testing/cli-integ/lib/with-cdk-app.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@aws-cdk-testing/cli-integ/lib/with-cdk-app.ts b/packages/@aws-cdk-testing/cli-integ/lib/with-cdk-app.ts index 1c8f277e44efb..033d4c0a7b364 100644 --- a/packages/@aws-cdk-testing/cli-integ/lib/with-cdk-app.ts +++ b/packages/@aws-cdk-testing/cli-integ/lib/with-cdk-app.ts @@ -418,7 +418,7 @@ export class TestFixture extends ShellHelper { } public async cdkMigrate(language: string, stackName: string, inputPath?: string, options?: CdkCliOptions) { - console.log(path.join(__dirname, 'resources', 'templates', 'sqs-template.json').toString()); + console.log(path.join(__dirname, '..', 'resources', 'templates', 'sqs-template.json').toString()); return this.cdk([ 'migrate', '--language', From f319e9ce215448a7ecb7381e2cd6cfe2d54d74d2 Mon Sep 17 00:00:00 2001 From: Kendra Neil <53584728+TheRealAmazonKendra@users.noreply.github.com> Date: Tue, 10 Oct 2023 21:54:37 -0700 Subject: [PATCH 38/39] kendra is dumb --- packages/@aws-cdk-testing/cli-integ/lib/with-cdk-app.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@aws-cdk-testing/cli-integ/lib/with-cdk-app.ts b/packages/@aws-cdk-testing/cli-integ/lib/with-cdk-app.ts index 033d4c0a7b364..3495c865548a3 100644 --- a/packages/@aws-cdk-testing/cli-integ/lib/with-cdk-app.ts +++ b/packages/@aws-cdk-testing/cli-integ/lib/with-cdk-app.ts @@ -426,7 +426,7 @@ export class TestFixture extends ShellHelper { '--stack-name', stackName, '--from-path', - inputPath ?? path.join(__dirname, 'resources', 'templates', 'sqs-template.json').toString(), + inputPath ?? path.join(__dirname, '..', 'resources', 'templates', 'sqs-template.json').toString(), ...(options?.options ?? []), ], options); } From b6aa7ecd58e81cca474be2f1b9c4ebc6759d69f5 Mon Sep 17 00:00:00 2001 From: Kendra Neil <53584728+TheRealAmazonKendra@users.noreply.github.com> Date: Wed, 11 Oct 2023 15:46:22 -0700 Subject: [PATCH 39/39] remove test updates and only update init --- .../cli-integ/lib/with-cdk-app.ts | 52 ------------------- .../cli-integ/resources/integ.jest.config.js | 2 +- .../resources/templates/sqs-template.json | 36 ------------- .../tests/cli-integ-tests/cli.integtest.ts | 26 +--------- 4 files changed, 2 insertions(+), 114 deletions(-) delete mode 100644 packages/@aws-cdk-testing/cli-integ/resources/templates/sqs-template.json diff --git a/packages/@aws-cdk-testing/cli-integ/lib/with-cdk-app.ts b/packages/@aws-cdk-testing/cli-integ/lib/with-cdk-app.ts index 3495c865548a3..a37edcb206dd4 100644 --- a/packages/@aws-cdk-testing/cli-integ/lib/with-cdk-app.ts +++ b/packages/@aws-cdk-testing/cli-integ/lib/with-cdk-app.ts @@ -84,40 +84,6 @@ export function withCdkApp( }; } -export function withCdkMigrateApp(language: string, block: (context: TestFixture) => Promise) { - return async (context: A) => { - const stackName = `cdk-migrate-${language}-integ-${context.randomString}`; - const integTestDir = path.join(os.tmpdir(), `cdk-migrate-${language}-integ-${context.randomString}`); - - context.output.write(` Stack name: ${stackName}\n`); - context.output.write(` Test directory: ${integTestDir}\n`); - - const awsClients = await AwsClients.default(context.output); - fs.mkdirSync(integTestDir); - const fixture = new TestFixture( - integTestDir, - stackName, - context.output, - awsClients, - context.randomString, - ); - - let success = true; - try { - await block(fixture); - } catch (e) { - success = false; - throw e; - } finally { - if (process.env.INTEG_NO_CLEAN) { - context.log(`Left test directory in '${integTestDir}' ($INTEG_NO_CLEAN)`); - } else { - await fixture.dispose(success); - } - } - }; -} - export function withMonolithicCfnIncludeCdkApp(block: (context: TestFixture) => Promise) { return async (context: A) => { const uberPackage = process.env.UBERPACKAGE; @@ -175,10 +141,6 @@ export function withDefaultFixture(block: (context: TestFixture) => Promise Promise) { - return withAws(withTimeout(DEFAULT_TEST_TIMEOUT_S, withCdkMigrateApp(language, block))); -} - export interface DisableBootstrapContext { /** * Whether to disable creating the default bootstrap @@ -417,20 +379,6 @@ export class TestFixture extends ShellHelper { }); } - public async cdkMigrate(language: string, stackName: string, inputPath?: string, options?: CdkCliOptions) { - console.log(path.join(__dirname, '..', 'resources', 'templates', 'sqs-template.json').toString()); - return this.cdk([ - 'migrate', - '--language', - language, - '--stack-name', - stackName, - '--from-path', - inputPath ?? path.join(__dirname, '..', 'resources', 'templates', 'sqs-template.json').toString(), - ...(options?.options ?? []), - ], options); - } - public async cdk(args: string[], options: CdkCliOptions = {}) { const verbose = options.verbose ?? true; diff --git a/packages/@aws-cdk-testing/cli-integ/resources/integ.jest.config.js b/packages/@aws-cdk-testing/cli-integ/resources/integ.jest.config.js index 06ad36ecb54c8..e72d95ff70da6 100644 --- a/packages/@aws-cdk-testing/cli-integ/resources/integ.jest.config.js +++ b/packages/@aws-cdk-testing/cli-integ/resources/integ.jest.config.js @@ -17,7 +17,7 @@ module.exports = { testTimeout: 300000, // Affects test.concurrent(), these are self-limiting anyway - maxWorkers: '50%', + maxConcurrency: 10, reporters: [ "default", [ "jest-junit", { suiteName: "jest tests", outputDirectory: "coverage" } ] diff --git a/packages/@aws-cdk-testing/cli-integ/resources/templates/sqs-template.json b/packages/@aws-cdk-testing/cli-integ/resources/templates/sqs-template.json deleted file mode 100644 index 57c9ef5d12a3d..0000000000000 --- a/packages/@aws-cdk-testing/cli-integ/resources/templates/sqs-template.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "AWSTemplateFormatVersion": "2010-09-09", - "Description": "AWS CloudFormation Sample Template SQS_With_CloudWatch_Alarms: Sample template showing how to create an SQS queue with AWS CloudWatch alarms on queue depth.", - "Resources": { - "MyQueue": { - "Type": "AWS::SQS::Queue", - "Properties": {} - } - }, - "Outputs": { - "QueueURL": { - "Description": "URL of newly created SQS Queue", - "Value": { - "Ref": "MyQueue" - } - }, - "QueueARN": { - "Description": "ARN of newly created SQS Queue", - "Value": { - "Fn::GetAtt": [ - "MyQueue", - "Arn" - ] - } - }, - "QueueName": { - "Description": "Name newly created SQS Queue", - "Value": { - "Fn::GetAtt": [ - "MyQueue", - "QueueName" - ] - } - } - } -} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts index bdff36822cbaa..b5b55ba5a6a75 100644 --- a/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts +++ b/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts @@ -1,7 +1,7 @@ import { promises as fs, existsSync } from 'fs'; import * as os from 'os'; import * as path from 'path'; -import { integTest, cloneDirectory, shell, withDefaultFixture, retry, sleep, randomInteger, withSamIntegrationFixture, RESOURCES_DIR, withCDKMigrateFixture } from '../../lib'; +import { integTest, cloneDirectory, shell, withDefaultFixture, retry, sleep, randomInteger, withSamIntegrationFixture, RESOURCES_DIR } from '../../lib'; jest.setTimeout(2 * 60 * 60_000); // Includes the time to acquire locks, worst-case single-threaded runtime @@ -571,30 +571,6 @@ integTest('deploy with role', withDefaultFixture(async (fixture) => { } })); -// TODO add go back in when template synths properly -['typescript', 'python', 'csharp', 'java'].forEach(language => { - integTest(`cdk migrate ${language}`, withCDKMigrateFixture(language, async (fixture) => { - await fixture.cdkMigrate(language, fixture.stackNamePrefix); - await fixture.shell(['ls']); - await fixture.shell(['pwd']); - await fixture.shell(['cd', fixture.stackNamePrefix]); - await fixture.shell(['ls']); - await fixture.shell(['pwd']); - - if (language === 'python') { - await fixture.shell(['pip', 'install', '-r', 'requirements.txt']); - } - - const stackArn = await fixture.cdkDeploy(fixture.stackNamePrefix, { neverRequireApproval: true, verbose: true, captureStderr: false }); - const response = await fixture.aws.cloudFormation('describeStacks', { - StackName: stackArn, - }); - - expect(response.Stacks?.[0].StackStatus).toEqual('CREATE_COMPLETE'); - await fixture.cdkDestroy(fixture.stackNamePrefix); - })); -}); - integTest('cdk diff', withDefaultFixture(async (fixture) => { const diff1 = await fixture.cdk(['diff', fixture.fullStackName('test-1')]); expect(diff1).toContain('AWS::SNS::Topic');