diff --git a/.taskcat.yml b/.taskcat.yml index 1637a64..fb2e189 100644 --- a/.taskcat.yml +++ b/.taskcat.yml @@ -1,5 +1,5 @@ project: - name: deoa + name: doea regions: - us-east-1 tests: @@ -8,18 +8,18 @@ tests: # GitHubToken: '{{resolve:secretsmanager:github/personal-access-token:SecretString}}' # SiteBucketName: delete-pmd-static-1021 # template: ./samples/static/pipeline.yml - # ec2: - # parameters: - # EmailAddress: fake-email@fake-fake-fake-email.com - # KeyName: paul-duvall-demo-us-east-1 - # CodeCommitS3Bucket: deoa-wkshop-abcd - # CodeCommitS3Key: deoa-ec2-examples.zip - # template: ./samples/ec2/pipeline.yml + ec2: + parameters: + EmailAddress: fake-email@fake-fake-fake-email.com + KeyName: '{{resolve:secretsmanager:ec2/keyname:SecretString}}' + CodeCommitS3Bucket: S3_BUCKET_TOKEN + CodeCommitS3Key: doea-ec2-examples.zip + template: ./samples/ec2/pipeline.yml beanstalk: parameters: EmailAddress: fake-email@fake-fake-fake-email.com - S3Bucket: deoa-wkshop-abcd - S3Key: deoa-beanstalk-examples.zip - CodeCommitS3Bucket: deoa-wkshop-abcd - CodeCommitS3Key: deoa-beanstalk-examples.zip + S3Bucket: S3_BUCKET_TOKEN + S3Key: doea-beanstalk-examples.zip + CodeCommitS3Bucket: S3_BUCKET_TOKEN + CodeCommitS3Key: doea-beanstalk-examples.zip template: ./samples/beanstalk/pipeline.yml \ No newline at end of file diff --git a/buildspec-setup.yml b/buildspec-setup.yml index 2082a1e..d79b4ed 100644 --- a/buildspec-setup.yml +++ b/buildspec-setup.yml @@ -5,21 +5,21 @@ phases: python: 3.7 commands: - python --version + pre_build: + commands: + - >- + ls -las + - chmod +x *.sh + - ./update-taskcat.sh $PIPELINE_BUCKET build: commands: - echo In buildspec-setup.yml Build started on `date` - >- - aws s3api list-buckets --query 'Buckets[?starts_with(Name, - `deoa-wkshop-abcd`) == `true`].[Name]' --output text | xargs -I {} aws s3 rb s3://{} --force - - 'sleep 10' - - 'aws s3 mb s3://deoa-wkshop-abcd' - - 'aws s3 sync . s3://deoa-wkshop-abcd' - - cd samples/ec2 - - zip deoa-ec2-examples.zip *.* - - 'aws s3 sync . s3://deoa-wkshop-abcd' - - cd ../beanstalk - - zip deoa-beanstalk-examples.zip *.* - - 'aws s3 sync . s3://deoa-wkshop-abcd' + zip -r doea-ec2-examples.zip ./samples/ec2 -x '*.git*' + - >- + zip -r doea-beanstalk-examples.zip ./samples/beanstalk -x '*.git*' + - >- + aws s3 sync . s3://$PIPELINE_BUCKET post_build: commands: - echo In buildspec-setup.yml Build completed on `date` diff --git a/buildspec.yml b/buildspec.yml index 496b1c7..2e0de31 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -14,8 +14,8 @@ phases: build: commands: - echo Build phase started on `date` - # - taskcat test run - - taskcat test run --no-delete + # - taskcat test run --no-delete + - taskcat test run -k --lint-disable post_build: commands: - echo Build completed on `date` diff --git a/html/beanstalk-cloudformation.html b/html/beanstalk-cloudformation.html index f8325fd..cf5b797 100755 --- a/html/beanstalk-cloudformation.html +++ b/html/beanstalk-cloudformation.html @@ -49,7 +49,7 @@

Parameters

RepositoryBranch: Description: The name of the branch for the CodeCommit repo Type: String - Default: master + Default: main AllowedPattern: "[\\x20-\\x7E]*" ConstraintDescription: Can contain only ASCII characters. S3Bucket: diff --git a/html/ec2-cloudformation.html b/html/ec2-cloudformation.html index b9a40c7..d28b206 100755 --- a/html/ec2-cloudformation.html +++ b/html/ec2-cloudformation.html @@ -55,7 +55,7 @@

Parameters

RepositoryBranch: Description: The name of the branch for the CodeCommit repo Type: String - Default: master + Default: main AllowedPattern: "[\\x20-\\x7E]*" ConstraintDescription: Can contain only ASCII characters. TagKey: diff --git a/html/ecs-cloudformation.html b/html/ecs-cloudformation.html index 1834f9b..8d842f8 100755 --- a/html/ecs-cloudformation.html +++ b/html/ecs-cloudformation.html @@ -31,7 +31,7 @@

Parameters

RepositoryBranch: Description: The name of the branch for the CodeCommit repo Type: String - Default: master + Default: main AllowedPattern: "[\\x20-\\x7E]*" ConstraintDescription: Can contain only ASCII characters. EmailAddress: diff --git a/launch-taskcat.sh b/launch-taskcat.sh index 5513c35..49cea4b 100755 --- a/launch-taskcat.sh +++ b/launch-taskcat.sh @@ -2,4 +2,4 @@ # sudo chmod +x *.sh # ./launch-taskcat.sh -aws cloudformation create-stack --stack-name taskcat-deoa --capabilities CAPABILITY_NAMED_IAM --disable-rollback --template-body file://pipeline-taskcat.yml +aws cloudformation create-stack --stack-name taskcat-doea --capabilities CAPABILITY_NAMED_IAM --disable-rollback --template-body file://pipeline-taskcat.yml diff --git a/pipeline-taskcat.yml b/pipeline-taskcat.yml index d59e453..41de8e2 100644 --- a/pipeline-taskcat.yml +++ b/pipeline-taskcat.yml @@ -144,7 +144,12 @@ Resources: Environment: Type: LINUX_CONTAINER ComputeType: BUILD_GENERAL1_SMALL - Image: "aws/codebuild/amazonlinux2-x86_64-standard:1.0" + Image: "aws/codebuild/amazonlinux2-x86_64-standard:3.0" + EnvironmentVariables: + - Name: PIPELINE_BUCKET + Type: PLAINTEXT + Value: + Fn::Sub: ${PipelineBucket} Source: Type: GITHUB Location: !Sub https://github.com/${GitHubUser}/${GitHubRepo}.git @@ -162,7 +167,7 @@ Resources: Environment: Type: LINUX_CONTAINER ComputeType: BUILD_GENERAL1_SMALL - Image: "aws/codebuild/amazonlinux2-x86_64-standard:1.0" + Image: "aws/codebuild/amazonlinux2-x86_64-standard:3.0" Source: Type: GITHUB Location: !Sub https://github.com/${GitHubUser}/${GitHubRepo}.git @@ -180,7 +185,7 @@ Resources: Environment: Type: LINUX_CONTAINER ComputeType: BUILD_GENERAL1_SMALL - Image: "aws/codebuild/amazonlinux2-x86_64-standard:1.0" + Image: "aws/codebuild/amazonlinux2-x86_64-standard:3.0" Source: Type: CODEPIPELINE TimeoutInMinutes: 60 @@ -196,7 +201,7 @@ Resources: Environment: Type: LINUX_CONTAINER ComputeType: BUILD_GENERAL1_SMALL - Image: "aws/codebuild/amazonlinux2-x86_64-standard:1.0" + Image: "aws/codebuild/amazonlinux2-x86_64-standard:3.0" Source: Type: CODEPIPELINE BuildSpec: !Sub | diff --git a/samples/README.md b/samples/README.md index a7e0868..098ea77 100644 --- a/samples/README.md +++ b/samples/README.md @@ -8,12 +8,11 @@ Solution | Launch Template | README ------------ | ------------- | ------------- **Static** | [![Launch Static Website Stack with CloudFormation](https://s3.amazonaws.com/cloudformation-examples/cloudformation-launch-stack.png)](https://us-east-1.console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/create/template?stackName=devops-essentials-static&templateURL=https://s3.amazonaws.com/www.devopsessentialsaws.com/samples/static/pipeline.yml) | [README](./static) **EC2** | [![Launch EC2 Stack with CloudFormation](https://s3.amazonaws.com/cloudformation-examples/cloudformation-launch-stack.png)](https://us-east-1.console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/create/template?stackName=devops-essentials-ec2&templateURL=https://s3.amazonaws.com/www.devopsessentialsaws.com/samples/ec2/pipeline.yml) | [README](./ec2) -**OpsWorks** | [![Launch OpsWorks Stack with CloudFormation](https://s3.amazonaws.com/cloudformation-examples/cloudformation-launch-stack.png)](https://console.aws.amazon.com/cloudformation/home?region=us-east-1#cstack=sn%7Edevops-essentials-opsworks%7Cturl%7Ehttps://s3.amazonaws.com/www.devopsessentialsaws.com/samples/opsworks/pipeline.yml) | [README](./opsworks) -**Elastic Beanstalk** | [![Launch Elastic Beanstalk Stack with CloudFormation](https://s3.amazonaws.com/cloudformation-examples/cloudformation-launch-stack.png)](https://console.aws.amazon.com/cloudformation/home?region=us-east-1#cstack=sn%7Edevops-essentials-beanstalk%7Cturl%7Ehttps://s3.amazonaws.com/www.devopsessentialsaws.com/samples/beanstalk/pipeline.yml) | [README](./beanstalk) -**ECS** | [![Launch ECS Stack with CloudFormation](https://s3.amazonaws.com/cloudformation-examples/cloudformation-launch-stack.png)](https://console.aws.amazon.com/cloudformation/home?region=us-east-1#cstack=sn%7Edevops-essentials-ecs%7Cturl%7Ehttps://s3.amazonaws.com/www.devopsessentialsaws.com/samples/ecs/pipeline.yml) | [README](./ecs) -**Serverless** | [![Launch Serverless Stack with CloudFormation](https://s3.amazonaws.com/cloudformation-examples/cloudformation-launch-stack.png)](https://console.aws.amazon.com/cloudformation/home?region=us-east-1#cstack=sn%7Edevops-essentials-serverless%7Cturl%7Ehttps://s3.amazonaws.com/www.devopsessentialsaws.com/samples/serverless/pipeline.yml) | [README](./serverless) -**Alexa** | [![Launch Serverless Stack for Alexa with CloudFormation](https://s3.amazonaws.com/cloudformation-examples/cloudformation-launch-stack.png)](https://console.aws.amazon.com/cloudformation/home?region=us-east-1#cstack=sn%7Edevops-essentials-alexa%7Cturl%7Ehttps://s3.amazonaws.com/www.devopsessentialsaws.com/samples/serverless/alexa/pipeline.yml) | [README](./serverless/alexa) - +**OpsWorks** | [![Launch OpsWorks Stack with CloudFormation](https://s3.amazonaws.com/cloudformation-examples/cloudformation-launch-stack.png)](https://us-east-1.console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/create/template?stackName=devops-essentials-opsworks&templateURL=https://s3.amazonaws.com/www.devopsessentialsaws.com/samples/opsworks/pipeline.yml) | [README](./opsworks) +**Elastic Beanstalk** | [![Launch Elastic Beanstalk Stack with CloudFormation](https://s3.amazonaws.com/cloudformation-examples/cloudformation-launch-stack.png)](https://us-east-1.console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/create/template?stackName=devops-essentials-beanstalk&templateURL=https://s3.amazonaws.com/www.devopsessentialsaws.com/samples/beanstalk/pipeline.yml) | [README](./beanstalk) +**ECS** | [![Launch ECS Stack with CloudFormation](https://s3.amazonaws.com/cloudformation-examples/cloudformation-launch-stack.png)](https://us-east-1.console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/create/template?stackName=devops-essentials-ecs&templateURL=https://s3.amazonaws.com/www.devopsessentialsaws.com/samples/ecs/pipeline.yml) | [README](./ecs) +**Serverless** | [![Launch Serverless Stack with CloudFormation](https://s3.amazonaws.com/cloudformation-examples/cloudformation-launch-stack.png)](https://us-east-1.console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/create/template?stackName=devops-essentials-serverless&templateURL=https://s3.amazonaws.com/www.devopsessentialsaws.com/samples/serverless/pipeline.yml) | [README](./serverless) +**Alexa** | [![Launch Serverless Stack for Alexa with CloudFormation](https://s3.amazonaws.com/cloudformation-examples/cloudformation-launch-stack.png)](https://us-east-1.console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/create/template?stackName=devops-essentials-alexa&templateURL=https://s3.amazonaws.com/www.devopsessentialsaws.com/samples/serverless/alexa/pipeline.yml) | [README](./serverless/alexa) # Changes 1. Go to [Find a Color](http://htmlcolorcodes.com/) diff --git a/samples/beanstalk/README.md b/samples/beanstalk/README.md index f551cfe..c54e44d 100644 --- a/samples/beanstalk/README.md +++ b/samples/beanstalk/README.md @@ -4,32 +4,35 @@ AWS Elastic Beanstalk Examples. # Overview This repo is a demonstration of Continuous Delivery of a static website to Elastic Beanstalk via CodePipeline, CodeCommit, CodeBuild, and Elastic Beanstalk. Ensure you've configured the [Prerequisites](https://github.com/stelligent/devops-essentials/wiki/Prerequisites) before launching the stack below. -# Upload html.zip file - -1. Download [html.zip](https://github.com/stelligent/devops-essentials/blob/master/samples/beanstalk/html.zip) from GitHub -1. Create a new S3 bucket and make note of the unique bucketname name you created # Launch Stack +From your [AWS Cloud9](https://github.com/paulduvall/aws-compliance-workshop/wiki/0.2#setup-aws-cloud9) terminal, type the following to setup your directory structure: + +``` +sudo rm -rf ~/environment/tmp-doea +cd ~/environment +aws s3 mb s3://doea-eb-$(aws sts get-caller-identity --output text --query 'Account') +aws s3 mb s3://doea-eb-sitebucket-$(aws sts get-caller-identity --output text --query 'Account') +git clone https://github.com/PaulDuvall/devops-essentials.git tmp-doea +cd tmp-doea/samples/beanstalk +zip -r doea-eb-samples.zip . -x '*.git*' +aws s3 sync ~/environment/tmp-doea/samples/beanstalk/ s3://doea-eb-$(aws sts get-caller-identity --output text --query 'Account') +aws s3 sync ~/environment/tmp-doea/samples/beanstalk s3://doea-eb-sitebucket-$(aws sts get-caller-identity --output text --query 'Account') +``` +## Launch the CloudFormation stack from the CLI -# Configure Solution +From your Cloud9 terminal, type the following: -## Before Launching the Stack +``` +aws cloudformation create-stack --stack-name doea-beanstalk --capabilities CAPABILITY_NAMED_IAM --disable-rollback --template-body file:///home/ec2-user/environment/tmp-doea/samples/beanstalk/pipeline.yml --parameters ParameterKey=EmailAddress,ParameterValue=fake-email@fake-fake-fake-email.com ParameterKey=CodeCommitS3Bucket,ParameterValue=doea-eb-$(aws sts get-caller-identity --output text --query 'Account') ParameterKey=CodeCommitS3Key,ParameterValue=doea-eb-samples.zip ParameterKey=S3Bucket,ParameterValue=doea-eb-sitebucket-$(aws sts get-caller-identity --output text --query 'Account') +``` -[![Launch CFN stack](https://s3.amazonaws.com/www.devopsessentialsaws.com/img/deploy-to-aws.png)](https://console.aws.amazon.com/cloudformation/home?region=us-east-1#cstack=sn%7Edevops-essentials-beanstalk%7Cturl%7Ehttps://s3.amazonaws.com/www.devopsessentialsaws.com/samples/beanstalk/pipeline.yml) -1. When launching the stack, enter the name of the S3 Bucket you created in the `S3Bucket` CloudFormation parameter ## After Launching the Stack 1. Once the CloudFormation stack is successful, select the checkbox next to the stack and click the **Outputs** tab. 1. From Outputs, click on the **PipelineUrl** output. The Source action will be in a failed state. -1. From the CodePipeline Source action, click on the CodeCommit provider and copy the **git clone** statement provided by CodeCommit -1. Paste the command in your Terminal -1. From [this](../beanstalk) folder, copy all of its *contents* to your locally cloned Git repo -1. From your Terminal, type `git add .` -1. From your Terminal, type `git commit -am "add new files"` -1. From your Terminal, type `git push` -1. Go back to your pipeline in CodePipeline and see the changes flow through the pipeline 1. Once the pipeline is complete, go to your CloudFormation Outputs and click on the **SiteUrl** Output # Resources diff --git a/samples/beanstalk/pipeline.yml b/samples/beanstalk/pipeline.yml index e3ff43f..cde54f4 100644 --- a/samples/beanstalk/pipeline.yml +++ b/samples/beanstalk/pipeline.yml @@ -11,7 +11,7 @@ Parameters: RepositoryBranch: Description: The name of the branch for the CodeCommit repo Type: String - Default: master + Default: main AllowedPattern: "[\\x20-\\x7E]*" ConstraintDescription: Can contain only ASCII characters. CodeCommitS3Bucket: @@ -26,7 +26,7 @@ Parameters: AllowedPattern: "[\\x20-\\x7E]*" ConstraintDescription: Can contain only ASCII characters. S3Key: - Description: S3 Bucket that hosts the application code + Description: Zip file that contains application code Type: String Default: html.zip AllowedPattern: "[\\x20-\\x7E]*" @@ -34,7 +34,7 @@ Parameters: MySolutionStackName: Description: Name of the current solution stack name. See https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/concepts.platforms.html Type: String - Default: "64bit Amazon Linux 2018.03 v4.14.1 running Node.js" + Default: 64bit Amazon Linux 2 v5.2.0 running Node.js 12 ConstraintDescription: Can contain only ASCII characters. Metadata: AWS::CloudFormation::Interface: @@ -122,6 +122,33 @@ Resources: Ref: nodeConfigurationTemplate VersionLabel: Ref: nodeApplicationVersion + OptionSettings: + - Namespace: 'aws:autoscaling:launchconfiguration' + OptionName: IamInstanceProfile + Value: !Ref InstanceProfile + - Namespace: 'aws:elasticbeanstalk:environment' + OptionName: ServiceRole + Value: !Ref InstanceProfileRole + InstanceProfileRole: + Type: AWS::IAM::Role + Properties: + AssumeRolePolicyDocument: + Version: "2012-10-17" + Statement: + - + Effect: "Allow" + Principal: + Service: + - "ec2.amazonaws.com" + Action: + - "sts:AssumeRole" + ManagedPolicyArns: + - "arn:aws:iam::aws:policy/AWSElasticBeanstalkWorkerTier" + InstanceProfile: + Type: "AWS::IAM::InstanceProfile" + Properties: + Roles: + - !Ref 'InstanceProfileRole' CodePipelineRole: Type: AWS::IAM::Role Properties: @@ -189,7 +216,8 @@ Resources: Version: '2012-10-17' ArtifactBucket: Type: AWS::S3::Bucket - DeletionPolicy: Delete + DeletionPolicy: Retain + UpdateReplacePolicy: Retain CodePipelineStack: Type: AWS::CodePipeline::Pipeline DependsOn: diff --git a/samples/beanstalk/public/beanstalk-cloudformation.html b/samples/beanstalk/public/beanstalk-cloudformation.html index c1efe97..1574067 100755 --- a/samples/beanstalk/public/beanstalk-cloudformation.html +++ b/samples/beanstalk/public/beanstalk-cloudformation.html @@ -49,7 +49,7 @@

Parameters

RepositoryBranch: Description: The name of the branch for the CodeCommit repo Type: String - Default: master + Default: main AllowedPattern: "[\\x20-\\x7E]*" ConstraintDescription: Can contain only ASCII characters. S3Bucket: diff --git a/samples/beanstalk/public/ec2-cloudformation.html b/samples/beanstalk/public/ec2-cloudformation.html index 9d32c68..e820307 100755 --- a/samples/beanstalk/public/ec2-cloudformation.html +++ b/samples/beanstalk/public/ec2-cloudformation.html @@ -56,7 +56,7 @@

Parameters

"RepositoryBranch":{ "Description":"The name of the branch for the CodeCommit repo", "Type":"String", - "Default":"master", + "Default":"main", "AllowedPattern":"[\\x20-\\x7E]*", "ConstraintDescription":"Can contain only ASCII characters." }, diff --git a/samples/ec2/html/beanstalk-cloudformation.html b/samples/ec2/html/beanstalk-cloudformation.html index c1efe97..1574067 100755 --- a/samples/ec2/html/beanstalk-cloudformation.html +++ b/samples/ec2/html/beanstalk-cloudformation.html @@ -49,7 +49,7 @@

Parameters

RepositoryBranch: Description: The name of the branch for the CodeCommit repo Type: String - Default: master + Default: main AllowedPattern: "[\\x20-\\x7E]*" ConstraintDescription: Can contain only ASCII characters. S3Bucket: diff --git a/samples/ec2/html/ecs-cloudformation.html b/samples/ec2/html/ecs-cloudformation.html index 7e801dc..269ecc4 100755 --- a/samples/ec2/html/ecs-cloudformation.html +++ b/samples/ec2/html/ecs-cloudformation.html @@ -57,7 +57,7 @@

Parameters

"RepositoryBranch":{ "Description":"The name of the branch for the CodeCommit repo", "Type":"String", - "Default":"master", + "Default":"main", "AllowedPattern":"[\\x20-\\x7E]*", "ConstraintDescription":"Can contain only ASCII characters." }, diff --git a/samples/ec2/html/opsworks-cloudformation.html b/samples/ec2/html/opsworks-cloudformation.html index fddb170..f863ff6 100755 --- a/samples/ec2/html/opsworks-cloudformation.html +++ b/samples/ec2/html/opsworks-cloudformation.html @@ -56,7 +56,7 @@

Parameters

"RepositoryBranch":{ "Description":"The name of the branch for the CodeCommit repo", "Type":"String", - "Default":"master", + "Default":"main", "AllowedPattern":"[\\x20-\\x7E]*", "ConstraintDescription":"Can contain only ASCII characters." } diff --git a/samples/ec2/html/serverless-cloudformation.html b/samples/ec2/html/serverless-cloudformation.html index 3d742aa..032120a 100755 --- a/samples/ec2/html/serverless-cloudformation.html +++ b/samples/ec2/html/serverless-cloudformation.html @@ -57,7 +57,7 @@

Parameters

"RepositoryBranch":{ "Description":"The name of the branch for the CodeCommit repo", "Type":"String", - "Default":"master", + "Default":"main", "AllowedPattern":"[\\x20-\\x7E]*", "ConstraintDescription":"Can contain only ASCII characters." }, diff --git a/samples/ec2/pipeline.yml b/samples/ec2/pipeline.yml index a4d990b..61a2c4c 100644 --- a/samples/ec2/pipeline.yml +++ b/samples/ec2/pipeline.yml @@ -10,7 +10,7 @@ Parameters: RepositoryBranch: Description: The name of the branch for the CodeCommit repo Type: String - Default: master + Default: main AllowedPattern: "[\\x20-\\x7E]*" ConstraintDescription: Can contain only ASCII characters. TagKey: @@ -27,7 +27,7 @@ Parameters: KeyName: Description: Name of an existing Amazon EC2 key pair to enable SSH access to the instances. - Type: AWS::EC2::KeyPair::KeyName + Type: String CodeCommitS3Bucket: Description: S3 bucket that holds zip of source code for CodeCommit Repo Type: String @@ -85,7 +85,8 @@ Resources: pipeline: "$.detail.pipeline" ArtifactBucket: Type: AWS::S3::Bucket - DeletionPolicy: Delete + DeletionPolicy: Retain + UpdateReplacePolicy: Retain CodeBuildRole: Type: AWS::IAM::Role Properties: diff --git a/samples/ecs/pipeline.yml b/samples/ecs/pipeline.yml index 53f4a1d..fa5b66d 100644 --- a/samples/ecs/pipeline.yml +++ b/samples/ecs/pipeline.yml @@ -7,7 +7,7 @@ Parameters: RepositoryBranch: Description: The name of the branch for the CodeCommit repo Type: String - Default: master + Default: main AllowedPattern: "[\\x20-\\x7E]*" ConstraintDescription: Can contain only ASCII characters. EmailAddress: diff --git a/samples/ecs/templates/deployment-pipeline.yml b/samples/ecs/templates/deployment-pipeline.yml index e88906f..c984f7b 100644 --- a/samples/ecs/templates/deployment-pipeline.yml +++ b/samples/ecs/templates/deployment-pipeline.yml @@ -2,7 +2,7 @@ Parameters: RepositoryBranch: Description: The name of the branch for the CodeCommit repo Type: String - Default: master + Default: main AllowedPattern: "[\\x20-\\x7E]*" ConstraintDescription: Can contain only ASCII characters. EmailAddress: diff --git a/samples/opsworks/html/beanstalk-cloudformation.html b/samples/opsworks/html/beanstalk-cloudformation.html index c1efe97..1574067 100755 --- a/samples/opsworks/html/beanstalk-cloudformation.html +++ b/samples/opsworks/html/beanstalk-cloudformation.html @@ -49,7 +49,7 @@

Parameters

RepositoryBranch: Description: The name of the branch for the CodeCommit repo Type: String - Default: master + Default: main AllowedPattern: "[\\x20-\\x7E]*" ConstraintDescription: Can contain only ASCII characters. S3Bucket: diff --git a/samples/opsworks/pipeline.yml b/samples/opsworks/pipeline.yml index 1031e91..986447e 100644 --- a/samples/opsworks/pipeline.yml +++ b/samples/opsworks/pipeline.yml @@ -11,7 +11,7 @@ Parameters: RepositoryBranch: Description: The name of the branch for the CodeCommit repo Type: String - Default: master + Default: main AllowedPattern: "[\\x20-\\x7E]*" ConstraintDescription: Can contain only ASCII characters. Metadata: diff --git a/samples/serverless/alexa/pipeline.yml b/samples/serverless/alexa/pipeline.yml index ad7906a..1a5fe40 100644 --- a/samples/serverless/alexa/pipeline.yml +++ b/samples/serverless/alexa/pipeline.yml @@ -8,7 +8,7 @@ Parameters: RepositoryBranch: Description: The name of the branch for the CodeCommit repo Type: String - Default: master + Default: main AllowedPattern: "[\\x20-\\x7E]*" ConstraintDescription: Can contain only ASCII characters. Resources: diff --git a/samples/training/pipeline.yml b/samples/training/pipeline.yml index 3fb62be..052dd40 100644 --- a/samples/training/pipeline.yml +++ b/samples/training/pipeline.yml @@ -15,7 +15,7 @@ Parameters: RepositoryBranch: Description: The name of the branch for the CodeCommit repo Type: String - Default: master + Default: main AllowedPattern: "[\\x20-\\x7E]*" ConstraintDescription: Can contain only ASCII characters. TagKey: diff --git a/update-taskcat.sh b/update-taskcat.sh new file mode 100755 index 0000000..747caad --- /dev/null +++ b/update-taskcat.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +# sudo chmod +x *.sh +# ./update-taskcat.sh my-pipeline-name-bucket + +set -euo pipefail +IFS=$'\n\t' + +#/ Usage: update-taskcat.sh [PIPELINE_BUCKET] +#/ Description: Change all S3_BUCKET_TOKEN references in the TaskCat configuration file to the autogenerated S3 Bucket name used as the ArtifactStore for CodePipeline in the pipeline-taskcat.yml template. +#/ Examples: +#/ launch-stack.sh (launches a stack using the the env var PIPELINE_BUCKET, or shows you these docs if it is unset) +#/ update-taskcat.sh my-pipeline-bucket-name +#/ Options: +#/ --help: Display this help message +usage() { grep '^#/' "$0" | cut -c4- ; exit 1 ; } +expr "$*" : ".*--help" > /dev/null && usage + +readonly LOG_FILE="/tmp/$(basename "$0").log" +info() { echo "[INFO] $@" | tee -a "$LOG_FILE" >&2 ; } +warning() { echo "[WARNING] $@" | tee -a "$LOG_FILE" >&2 ; } +error() { echo "[ERROR] $@" | tee -a "$LOG_FILE" >&2 ; } +fatal() { echo "[FATAL] $@" | tee -a "$LOG_FILE" >&2 ; exit 1 ; } + +PIPELINE_BUCKET=${1:-${PIPELINE_BUCKET:-}} +if [ -z "$PIPELINE_BUCKET" ]; then + usage +fi + +echo "Running update-taskcat.sh" + +PIPELINE_BUCKET=${1:-PIPELINE_BUCKETisrequired} + +echo "$PIPELINE_BUCKET is $PIPELINE_BUCKET" + +echo "Change all S3_BUCKET_TOKEN references in the TaskCat configuration file to the autogenerated S3 Bucket name used as the ArtifactStore for CodePipeline in the pipeline-taskcat.yml template" +sed -i "s/S3_BUCKET_TOKEN/$PIPELINE_BUCKET/g" .taskcat.yml + +echo "Updated update-taskcat.sh" + +cat .taskcat.yml \ No newline at end of file