From 94c116345e1fd00e055998fa38ed0a6bf764d0c7 Mon Sep 17 00:00:00 2001 From: Laurent Mathieu Date: Mon, 22 Jul 2024 11:45:41 -0400 Subject: [PATCH 1/5] feat: improve bootstraping documentation --- examples/tm-webapp/README.md | 43 +++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/examples/tm-webapp/README.md b/examples/tm-webapp/README.md index 4a0c6d9..ee89f44 100644 --- a/examples/tm-webapp/README.md +++ b/examples/tm-webapp/README.md @@ -15,13 +15,46 @@ The `cdk.json` file tells the CDK Toolkit how to execute your app. # Bootstrap projet -## Create a mirroring before begging the deploy +## Install packages + +At the root of the project: +``` +npm install +npx projen +``` + +[!WARNING] +Do not run npm install in the examples folder. There shall be only one node_modules folder at the root of the project. + +## Deploy cdk bootstrap + +``` +cdk bootstrap +``` + +When adding a new region, you must bootstrap it by running the bootstrap command again. + +## Create two CodeCommit repositories + +* infrastructure +* application + +## Configure mirroring if you wish to deploy from something else than CodeCommit [GitLab to CodeCommit](https://docs.gitlab.com/ee/user/project/repository/mirror/push.html) [Azure DevOps to CodeCommit](https://aws.amazon.com/blogs/devops/use-aws-codecommit-to-mirror-an-azure-devops-repository-using-an-azure-devops-pipeline/) -## Create SSM entries for each account that is going to be used +## Deploy + +For the first deploy, you need to specify some parameters: + +| Parameter | Description | +|-------------------------------------------|------------------------------------------------------| +| CommonStack:customHttpHeaderValue | Secret header between CloudFront and Load-Balancer | +| CommonStack:domainName | Domain name for the application | +| CommonStack:hostedZoneId | Hosted Zone ID for the domain | + -* Default repository branch main `aws ssm put-parameter --name "repositoryBranch" --type "String" --value "main"` -* Default domain `aws ssm put-parameter --name "domain" --type "String" --value "main"` -* Create a vakye Secure `aws ssm put-parameter --name "secure-parameter-name" --type "SecureString" --value "secure-parameter-value"` \ No newline at end of file +``` +cdk deploy --all --parameters CommonStack:customHttpHeaderValue='value' --parameters CommonStack:domainName=value --parameters CommonStack:hostedZoneId=value +``` From bb4b3cb0e62a0aad6294caad2c7c0907ad3c1c63 Mon Sep 17 00:00:00 2001 From: tm-lmathieu Date: Tue, 6 Aug 2024 12:47:19 -0400 Subject: [PATCH 2/5] docs: update way of handling parameters --- examples/tm-webapp/README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/examples/tm-webapp/README.md b/examples/tm-webapp/README.md index ee89f44..a8c7bea 100644 --- a/examples/tm-webapp/README.md +++ b/examples/tm-webapp/README.md @@ -46,15 +46,16 @@ When adding a new region, you must bootstrap it by running the bootstrap command ## Deploy -For the first deploy, you need to specify some parameters: +Befor the first deploy, you need to create some parameters in Parameter Store: | Parameter | Description | |-------------------------------------------|------------------------------------------------------| -| CommonStack:customHttpHeaderValue | Secret header between CloudFront and Load-Balancer | -| CommonStack:domainName | Domain name for the application | -| CommonStack:hostedZoneId | Hosted Zone ID for the domain | +| branchNameParam | Name of the branch that will trigger the pipeline | +| customHttpHeaderValue | Secret header between CloudFront and Load-Balancer | +| domain | Domain name for the application | +| hostedZoneId | Hosted Zone ID for the domain | ``` -cdk deploy --all --parameters CommonStack:customHttpHeaderValue='value' --parameters CommonStack:domainName=value --parameters CommonStack:hostedZoneId=value +aws ssm put-parameter --name "" --type "String" --value "" ``` From 473f9cdc9af083f703c09fba7dc69bf5c3cb8415 Mon Sep 17 00:00:00 2001 From: tm-lmathieu Date: Wed, 7 Aug 2024 14:29:04 -0400 Subject: [PATCH 3/5] docs: explain how to change removal policy and destroy --- examples/tm-webapp/README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/examples/tm-webapp/README.md b/examples/tm-webapp/README.md index a8c7bea..e16e3b2 100644 --- a/examples/tm-webapp/README.md +++ b/examples/tm-webapp/README.md @@ -46,7 +46,7 @@ When adding a new region, you must bootstrap it by running the bootstrap command ## Deploy -Befor the first deploy, you need to create some parameters in Parameter Store: +Before the first deploy, you need to create some parameters in Parameter Store: | Parameter | Description | |-------------------------------------------|------------------------------------------------------| @@ -59,3 +59,14 @@ Befor the first deploy, you need to create some parameters in Parameter Store: ``` aws ssm put-parameter --name "" --type "String" --value "" ``` +### Modifying removal policy to allow destuction of everything + +We're using an aspect to apply the RETAIN policy to every resource in the application. Before destroying, we must deploy change it to DESTROY. + +``` +cdk deploy "**" --context removalPolicy=DESTROY --concurrency 10 +``` +Then we can destroy everything +``` +cdk destroy "**" --concurrency 10 +``` From 10dd5a5e322afb7a1764f9c80817d71f12d9f776 Mon Sep 17 00:00:00 2001 From: tm-lmathieu Date: Fri, 9 Aug 2024 12:18:04 -0400 Subject: [PATCH 4/5] fix(tm-webapp): fix domainName parameter --- examples/tm-webapp/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tm-webapp/README.md b/examples/tm-webapp/README.md index e16e3b2..5d36ce3 100644 --- a/examples/tm-webapp/README.md +++ b/examples/tm-webapp/README.md @@ -52,7 +52,7 @@ Before the first deploy, you need to create some parameters in Parameter Store: |-------------------------------------------|------------------------------------------------------| | branchNameParam | Name of the branch that will trigger the pipeline | | customHttpHeaderValue | Secret header between CloudFront and Load-Balancer | -| domain | Domain name for the application | +| domainName | Domain name for the application | | hostedZoneId | Hosted Zone ID for the domain | From d6f8e888cc78fc7958cb3156718299c81048d581 Mon Sep 17 00:00:00 2001 From: tm-lmathieu Date: Mon, 12 Aug 2024 10:51:16 -0400 Subject: [PATCH 5/5] feat(tm-webapp): improving deploy documentation --- examples/tm-webapp/README.md | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/examples/tm-webapp/README.md b/examples/tm-webapp/README.md index 5d36ce3..3c4141e 100644 --- a/examples/tm-webapp/README.md +++ b/examples/tm-webapp/README.md @@ -34,17 +34,26 @@ cdk bootstrap When adding a new region, you must bootstrap it by running the bootstrap command again. -## Create two CodeCommit repositories +## CodeCommit repositories (soon to be deprecated) +Create two CodeCommit repositories in your main region: * infrastructure * application +Push the CDK app repository to infrastructure. + +To the application repository, push a simple app to start with. Create a folder named docker. In that folder, create a Dockerfile that contains: +``` +FROM httpd +``` +Once the infrastructure is deployed with the your application's configuration, you will overwrite the application repository with your application. + ## Configure mirroring if you wish to deploy from something else than CodeCommit [GitLab to CodeCommit](https://docs.gitlab.com/ee/user/project/repository/mirror/push.html) [Azure DevOps to CodeCommit](https://aws.amazon.com/blogs/devops/use-aws-codecommit-to-mirror-an-azure-devops-repository-using-an-azure-devops-pipeline/) -## Deploy +## Create parameters Before the first deploy, you need to create some parameters in Parameter Store: @@ -55,10 +64,13 @@ Before the first deploy, you need to create some parameters in Parameter Store: | domainName | Domain name for the application | | hostedZoneId | Hosted Zone ID for the domain | - ``` aws ssm put-parameter --name "" --type "String" --value "" ``` +### First deploy + +Run the deploy command and let the + ### Modifying removal policy to allow destuction of everything We're using an aspect to apply the RETAIN policy to every resource in the application. Before destroying, we must deploy change it to DESTROY.