From daf5ccfc547ff25ec976729fba0edba2213ca550 Mon Sep 17 00:00:00 2001 From: Clare Liguori Date: Fri, 21 Feb 2020 21:05:00 -0800 Subject: [PATCH] Tag more things --- chat-bot/StackConfig.json | 5 +++++ chat-bot/buildspec.yml | 1 + pipelines/README.md | 4 ++-- pipelines/src/api-service-pipeline.ts | 2 ++ pipelines/src/pipeline.ts | 2 ++ trivia-backend/README.md | 8 ++++---- trivia-backend/infra/cdk/StackConfig.json | 5 +++++ trivia-backend/infra/cdk/buildspec.yml | 1 + trivia-backend/infra/cdk/ecs-service.ts | 5 +++-- 9 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 chat-bot/StackConfig.json create mode 100644 trivia-backend/infra/cdk/StackConfig.json diff --git a/chat-bot/StackConfig.json b/chat-bot/StackConfig.json new file mode 100644 index 000000000..c44a3c6f0 --- /dev/null +++ b/chat-bot/StackConfig.json @@ -0,0 +1,5 @@ +{ + "Tags" : { + "project" : "reinvent-trivia" + } +} \ No newline at end of file diff --git a/chat-bot/buildspec.yml b/chat-bot/buildspec.yml index 762705231..b4440b6c9 100644 --- a/chat-bot/buildspec.yml +++ b/chat-bot/buildspec.yml @@ -17,4 +17,5 @@ artifacts: files: - chat-bot/TriviaGameChatBotTest.template.yaml - chat-bot/TriviaGameChatBotProd.template.yaml + - chat-bot/StackConfig.json discard-paths: yes diff --git a/pipelines/README.md b/pipelines/README.md index dc1bd3279..492bf18d4 100644 --- a/pipelines/README.md +++ b/pipelines/README.md @@ -15,12 +15,12 @@ In [src](src/) directory: Create a GitHub [personal access token](https://github.com/settings/tokens) with access to your fork of the repo, including "admin:repo_hook" and "repo" permissions. Then store the token in Secrets Manager: ``` -aws secretsmanager create-secret --region us-east-1 --name TriviaGitHubToken --secret-string +aws secretsmanager create-secret --region us-east-1 --name TriviaGitHubToken --tags Key=project,Value=reinvent-trivia --secret-string ``` Create an SNS topic for notifications about pipeline execution failures. An email address or to a [chat bot](https://docs.aws.amazon.com/chatbot/latest/adminguide/setting-up.html) can be subscribed to the topic to receive notifications about pipeline failures. ``` -aws sns create-topic --name reinvent-trivia-notifications --region us-east-1 +aws sns create-topic --name reinvent-trivia-notifications --tags Key=project,Value=reinvent-trivia --region us-east-1 ``` Follow the [CodeStar Notifications user guide](https://docs.aws.amazon.com/codestar-notifications/latest/userguide/set-up-sns.html) to configure the SNS topic to be able to receive notifications about pipeline failures. diff --git a/pipelines/src/api-service-pipeline.ts b/pipelines/src/api-service-pipeline.ts index c52a75a4a..213f362c6 100644 --- a/pipelines/src/api-service-pipeline.ts +++ b/pipelines/src/api-service-pipeline.ts @@ -133,6 +133,7 @@ class TriviaGameBackendPipelineStack extends cdk.Stack { runOrder: 1, adminPermissions: true, templatePath: buildArtifact.atPath(templatePrefix + 'Test.template.json'), + templateConfiguration: buildArtifact.atPath('StackConfig.json'), }), new actions.CloudFormationExecuteChangeSetAction({ actionName: 'ExecuteChangesTest', @@ -156,6 +157,7 @@ class TriviaGameBackendPipelineStack extends cdk.Stack { runOrder: 1, adminPermissions: true, templatePath: buildArtifact.atPath(templatePrefix + 'Prod.template.json'), + templateConfiguration: buildArtifact.atPath('StackConfig.json'), }), new actions.CloudFormationExecuteChangeSetAction({ actionName: 'ExecuteChangesProd', diff --git a/pipelines/src/pipeline.ts b/pipelines/src/pipeline.ts index 6b9058504..6a9fb391a 100644 --- a/pipelines/src/pipeline.ts +++ b/pipelines/src/pipeline.ts @@ -99,6 +99,7 @@ export class TriviaGameCfnPipeline extends cdk.Construct { runOrder: 1, adminPermissions: true, templatePath: buildArtifact.atPath(templatePrefix + 'Test.template.yaml'), + templateConfiguration: buildArtifact.atPath('StackConfig.json'), }), new actions.CloudFormationExecuteChangeSetAction({ actionName: 'ExecuteChangesTest', @@ -122,6 +123,7 @@ export class TriviaGameCfnPipeline extends cdk.Construct { runOrder: 1, adminPermissions: true, templatePath: buildArtifact.atPath(templatePrefix + 'Prod.template.yaml'), + templateConfiguration: buildArtifact.atPath('StackConfig.json'), }), new actions.CloudFormationExecuteChangeSetAction({ actionName: 'ExecuteChangesProd', diff --git a/trivia-backend/README.md b/trivia-backend/README.md index 84145c6e8..bef29ae47 100644 --- a/trivia-backend/README.md +++ b/trivia-backend/README.md @@ -7,17 +7,17 @@ The trivia backend is a REST API that serves questions and answers. A running e Create an ECR repository for both the base Docker image and the application image. ``` -aws ecr create-repository --region us-east-1 --repository-name reinvent-trivia-backend +aws ecr create-repository --region us-east-1 --tags Key=project,Value=reinvent-trivia --repository-name reinvent-trivia-backend -aws ecr create-repository --region us-east-1 --repository-name reinvent-trivia-backend-base +aws ecr create-repository --region us-east-1 --tags Key=project,Value=reinvent-trivia --repository-name reinvent-trivia-backend-base ``` Create AWS Certificate Manager certificates for the 'api' and 'test-api' subdomains, then put the unique ARN of those certificates in an AWS Systems Manager Parameter Store parameter. ``` -aws ssm put-parameter --region us-east-1 --name CertificateArn-api.reinvent-trivia.com --type String --value arn:aws:acm:... +aws ssm put-parameter --region us-east-1 --tags Key=project,Value=reinvent-trivia --name CertificateArn-api.reinvent-trivia.com --type String --value arn:aws:acm:... -aws ssm put-parameter --region us-east-1 --name CertificateArn-test-api.reinvent-trivia.com --type String --value arn:aws:acm:... +aws ssm put-parameter --region us-east-1 --tags Key=project,Value=reinvent-trivia --name CertificateArn-test-api.reinvent-trivia.com --type String --value arn:aws:acm:... ``` ## Customize diff --git a/trivia-backend/infra/cdk/StackConfig.json b/trivia-backend/infra/cdk/StackConfig.json new file mode 100644 index 000000000..c44a3c6f0 --- /dev/null +++ b/trivia-backend/infra/cdk/StackConfig.json @@ -0,0 +1,5 @@ +{ + "Tags" : { + "project" : "reinvent-trivia" + } +} \ No newline at end of file diff --git a/trivia-backend/infra/cdk/buildspec.yml b/trivia-backend/infra/cdk/buildspec.yml index ced7aca76..642f18b45 100644 --- a/trivia-backend/infra/cdk/buildspec.yml +++ b/trivia-backend/infra/cdk/buildspec.yml @@ -38,6 +38,7 @@ phases: - npm ci - npm run build - cdk synth -o build --app 'node ecs-service.js' + - cp StackConfig.json build/ artifacts: files: diff --git a/trivia-backend/infra/cdk/ecs-service.ts b/trivia-backend/infra/cdk/ecs-service.ts index 419fbdb1b..1b16bf7e9 100644 --- a/trivia-backend/infra/cdk/ecs-service.ts +++ b/trivia-backend/infra/cdk/ecs-service.ts @@ -2,7 +2,7 @@ import { Certificate } from '@aws-cdk/aws-certificatemanager'; import { Vpc } from '@aws-cdk/aws-ec2'; import { Repository } from '@aws-cdk/aws-ecr'; -import { Cluster, ContainerImage } from '@aws-cdk/aws-ecs'; +import { Cluster, ContainerImage, PropagatedTagSource } from '@aws-cdk/aws-ecs'; import { ApplicationLoadBalancedFargateService } from '@aws-cdk/aws-ecs-patterns'; import { HostedZone } from '@aws-cdk/aws-route53'; import { StringParameter } from '@aws-cdk/aws-ssm'; @@ -43,7 +43,8 @@ class TriviaBackendStack extends cdk.Stack { desiredCount: 3, domainName: props.domainName, domainZone, - certificate + certificate, + propagateTags: PropagatedTagSource.SERVICE, }); } }