Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Terraform module execution error #600

Merged
merged 189 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from 183 commits
Commits
Show all changes
189 commits
Select commit Hold shift + click to select a range
5f625ac
added .gitignore
Oct 29, 2021
ff378bc
added adf terraform role to global.yml
Oct 29, 2021
0aebbf8
Added DynamoDB permission to adf-codebuild-policy in deployment/globa…
Oct 29, 2021
c5121a6
added adf-terraform-role to Organization Policy adf-build/global.yml
Oct 29, 2021
fb49f24
added organizations:ListChildren to OrganizationsReadOnlyPolicy
Oct 29, 2021
6a9b868
added DynamoDB table for terraform lock to adf-bootstrap/deployment/g…
Oct 29, 2021
9cb0d83
added DynamoDB table for terraform lock to adf-bootstrap/deployment/g…
Oct 29, 2021
3ceabf4
added sample-terraform repository
Oct 29, 2021
8be3e71
Added tfvars examples
Oct 29, 2021
bc8d00c
clean comments
Oct 29, 2021
3711c3d
pull request template
Oct 29, 2021
ecc13aa
Define PULL REQUEST
Oct 29, 2021
c2657dd
clean PULL_REQUEST_TEMPLATE.md
Nov 5, 2021
4ce58cc
Update samples/sample-terraform/README.md
stemons Nov 5, 2021
ab48994
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Nov 5, 2021
d562c38
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Nov 5, 2021
dec1f81
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Nov 5, 2021
04c16db
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Nov 5, 2021
a2eb125
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Nov 5, 2021
2072056
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Nov 5, 2021
2278028
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Nov 5, 2021
c6d660d
removed .gitignore from sample-terraform
Nov 5, 2021
b18a0f5
Update samples/sample-terraform/README.md
stemons Nov 5, 2021
5f0ed7f
renamed tf_sec to tf_scan in sample-terraform
Nov 5, 2021
8952483
added more details to README.md regarding REGIONS parameters
Nov 5, 2021
948e147
removed restart_execution_on_update: true
Nov 5, 2021
5d18eeb
Update samples/sample-terraform/README.md
stemons Nov 5, 2021
23c8d55
Update samples/sample-terraform/README.md
stemons Nov 5, 2021
88449f7
Update samples/sample-terraform/README.md
stemons Nov 5, 2021
d173a2b
Update samples/sample-terraform/README.md
stemons Nov 5, 2021
d234a36
added latest terraform version in sample-terraform example
Nov 9, 2021
88f3e48
added terraform version support in documetation
Nov 9, 2021
cd71d42
fixed README.md format
Nov 9, 2021
0ffe83c
added tf pipeline documentation in user guide
Nov 9, 2021
7440ae3
added s3 public access block to terraform sample
Nov 9, 2021
bb52471
removed TF_STAGE as adf_terraform.sh input parameter
Nov 9, 2021
0b720d6
removed AWS_DEFAULT_REGION from tf_apply and tf_plan
Nov 9, 2021
30f116f
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Nov 9, 2021
0f630b4
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Nov 9, 2021
99e5e9f
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Nov 9, 2021
1625ae0
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Nov 9, 2021
e78223b
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Nov 9, 2021
85ce85c
revert to original PULL_REQUEST_TEMPLATE.md
Nov 12, 2021
793ab2c
clean .gitignore
Nov 12, 2021
3fa1b92
add logging module
Nov 12, 2021
99fa20d
added main
Nov 12, 2021
bb58170
undo linter changes
Nov 12, 2021
70196b8
removed artifact from tf_apply
Nov 12, 2021
9043135
added ondemand capacity to DynamoDB table
Nov 12, 2021
50e17b3
removed terraform role. This could be added in global-iam by the user
Nov 12, 2021
a81899e
added an example of terraform role. It must be uncommented by the use…
Nov 12, 2021
5138c97
added tf pre-requisites to user-guide
Nov 12, 2021
6568537
global vars to upper case
Nov 12, 2021
07d42a1
added tfrun function to avoid code repetition and add functionality t…
Nov 12, 2021
0b1f697
clean documentation
Nov 12, 2021
ed32b14
Update docs/user-guide.md
stemons Nov 19, 2021
926c9e3
Update docs/user-guide.md
stemons Nov 19, 2021
8c653aa
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Nov 19, 2021
e3762e7
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Nov 19, 2021
fb9759e
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Nov 19, 2021
7d5b8b0
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Nov 19, 2021
44c5401
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Nov 19, 2021
9fd62e2
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Nov 19, 2021
3e7ada5
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Nov 19, 2021
9180263
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Nov 19, 2021
e7e0679
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Nov 19, 2021
bafca0d
Update docs/user-guide.md
stemons Nov 19, 2021
e0be884
Update docs/user-guide.md
stemons Nov 19, 2021
c315037
Update docs/user-guide.md
stemons Nov 19, 2021
b0fcd77
Update docs/user-guide.md
stemons Nov 19, 2021
53572e7
Update docs/user-guide.md
stemons Nov 19, 2021
cfbbd37
Update docs/user-guide.md
stemons Nov 19, 2021
17a6c69
Update samples/sample-terraform/tf/s3.tf
stemons Nov 19, 2021
3a434ad
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bo…
stemons Nov 19, 2021
e9d3750
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Nov 19, 2021
256e75b
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Nov 19, 2021
4c034f0
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Nov 22, 2021
4a91739
removed extra ]
Nov 22, 2021
f9bdf73
changed session name
Nov 22, 2021
d98feb6
move TERRAFORM_VERSION variable to buildspec.yml
Nov 22, 2021
d5f72a2
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Nov 22, 2021
541262c
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Nov 22, 2021
90e3786
renamed environment variables
Nov 22, 2021
7401122
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Nov 23, 2021
0ea718b
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Nov 23, 2021
d02171c
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Nov 23, 2021
3d7fcb7
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Nov 23, 2021
abea92b
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Nov 23, 2021
b9da4dc
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Nov 23, 2021
4201301
Update docs/user-guide.md
stemons Nov 23, 2021
de8ca78
Update docs/user-guide.md
stemons Nov 23, 2021
d0a51b5
fixed toc identation
Nov 23, 2021
7a166a6
added details to terraform sections
Nov 23, 2021
db13877
Update docs/user-guide.md
stemons Nov 23, 2021
48ff0a5
Update docs/user-guide.md
stemons Nov 23, 2021
5466280
Update docs/user-guide.md
stemons Nov 23, 2021
31f52a3
Update docs/user-guide.md
stemons Nov 23, 2021
b9a6edf
Update docs/user-guide.md
stemons Nov 23, 2021
544a71b
Update samples/sample-terraform/README.md
stemons Nov 23, 2021
d5ed60a
Update samples/sample-terraform/README.md
stemons Nov 23, 2021
1f3dba1
renamed terraform to upper case and align content of README.md file i…
Nov 23, 2021
1d0496c
Update samples/sample-terraform/README.md
stemons Nov 23, 2021
135c6b3
Update samples/sample-terraform/buildspec.yml
stemons Nov 23, 2021
4b8a1fd
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Nov 23, 2021
ba5881c
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Nov 23, 2021
f99f07a
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Nov 23, 2021
33de671
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Nov 23, 2021
722fa0c
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Nov 23, 2021
fed666a
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Nov 23, 2021
8ec3acd
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Nov 23, 2021
2e3e139
removed Terraform IAM role and policy
Nov 23, 2021
c8aa794
added support to partitions
Nov 23, 2021
2cccef3
Update docs/user-guide.md
stemons Nov 24, 2021
75f97dc
Update docs/user-guide.md
stemons Nov 24, 2021
81c20d9
Update docs/user-guide.md
stemons Nov 24, 2021
9313a17
Update docs/user-guide.md
stemons Nov 24, 2021
196efb9
Update docs/user-guide.md
stemons Nov 24, 2021
b9dafee
Update samples/sample-terraform/README.md
stemons Nov 24, 2021
1398957
Update samples/sample-terraform/README.md
stemons Nov 24, 2021
fb84415
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bo…
stemons Nov 24, 2021
fb4c661
removed TerraformLockTable resource as already defined in regional.yml
Nov 24, 2021
f0d44f5
Update docs/user-guide.md
stemons Nov 24, 2021
9d2c71d
Update docs/user-guide.md
stemons Nov 24, 2021
beb9791
Update docs/user-guide.md
stemons Nov 24, 2021
fb743ac
Update samples/sample-terraform/README.md
stemons Nov 24, 2021
17818b9
Update samples/sample-terraform/README.md
stemons Nov 24, 2021
219186c
Merge remote-tracking branch 'upstream/master'
Nov 24, 2021
55c544d
added newline character
Dec 23, 2021
e2a93b1
added newline character
Dec 23, 2021
f98f3e5
added newline character
Dec 23, 2021
131c526
added docstring
Dec 23, 2021
4d97190
read CROSS_ACCOUNT_ACCESS_ROLE from parameter store
Dec 23, 2021
3fcda2d
replaced sample adf terraform policy example
Dec 23, 2021
e1ee1a6
replaced sample adf terraform policy example
Dec 23, 2021
868d88f
added details to adf terraform role description
Dec 23, 2021
a327b30
removed trailing spaces
Dec 23, 2021
c050572
added aws partition variable
Dec 23, 2021
35d3148
added init stage only as option
Dec 23, 2021
d50cc35
import extensions parameter in SSM Parameter Store of Management account
Dec 24, 2021
9742f97
import extensions parameter in SSM Parameter Store of Deployment acco…
Dec 24, 2021
a0b660b
added condition on DynamoDB table. Deploy only if Tf extension is ena…
Dec 24, 2021
b1e0020
added example in adfconfig related to Tf extension
Dec 24, 2021
5eccd06
added details related to terraform extension
Dec 24, 2021
6e2eb5c
added details related to terraform extension
Dec 24, 2021
9b6debb
fixed indentation
Dec 24, 2021
18fc837
renamed paginator variable
Jan 3, 2022
83efd01
Merge branch 'master' into master
StewartW Jan 5, 2022
31821a4
Merge branch 'master' into master
sbkok Jan 7, 2022
2b96912
Merge remote-tracking branch 'master' into PR #397
sbkok Mar 7, 2022
2f2f38b
Resolve W1514 - use open with encoding
sbkok Mar 7, 2022
f6c436c
Fix user guide target via tags
sbkok Mar 7, 2022
975c754
changed default codebuild image to STANDARD_5_0
May 27, 2022
3967707
Merge remote-tracking branch 'upstream/master' into stemons/master
sbkok Sep 16, 2022
3eb4732
Fix YAML lint issues
sbkok Sep 16, 2022
836bdb0
Fix CFN lint issues
sbkok Sep 16, 2022
0aa1f83
Fix MegaLint issues
sbkok Sep 16, 2022
02b7ee3
Merge remote-tracking branch 'upstream/master' into stemons-master
sbkok Sep 19, 2022
43e1cfd
Adding in default values for extensions
StewartW Sep 20, 2022
6eb593a
Merge branch 'master' of github.com:awslabs/aws-deployment-framework …
StewartW Sep 20, 2022
74b8049
Remove redundant paginator
sbkok Nov 3, 2022
0e433a8
Fix TF doc comments and links
sbkok Nov 3, 2022
81a3465
Fix TF line length findings
sbkok Nov 3, 2022
a5694a4
Revert default CodeBuild container, would introduce a breaking change
sbkok Nov 3, 2022
3be75e3
Replace redundant code writing extension parameters
sbkok Nov 3, 2022
f54c00f
Merge remote-tracking branch 'upstream/master' into stemons-master
sbkok Nov 4, 2022
ee1a0f8
fixed bash syntax
Jan 31, 2023
5e95abf
fixed parameter type to string
Jan 31, 2023
f39935c
merge to upstream master
Jan 31, 2023
87bb7a5
merge to main repo
Jan 31, 2023
1401215
merge user_guide
Jan 31, 2023
624c48f
merge to master
Jan 31, 2023
506810d
merge to master2
Jan 31, 2023
079559a
fixed double quotes bash syntax
Jan 31, 2023
fe8036d
added newline
Jan 31, 2023
d104f37
fixed bash syntax
Jan 31, 2023
83a2b28
added tfstate-lockfile DynamoDB table
Feb 3, 2023
911af75
fixed ADFTerraformExtensionEnabled condition
Feb 3, 2023
36477b3
removed trailing whitespace
Feb 3, 2023
af9a68a
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Mar 20, 2023
a392533
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
stemons Mar 20, 2023
cdea90a
Update get_accounts.py
stemons Mar 20, 2023
491d26e
Update src/lambda_codebase/initial_commit/bootstrap_repository/adf-bu…
sbkok Apr 19, 2023
e1c5cc4
Merge branch 'awslabs:master' into master
stemons May 4, 2023
51e6d85
added terraform destroy capabilities to terraform script
May 4, 2023
ea49db1
added terraform destroy buildspec file to samples
May 4, 2023
3c22d11
added terraform destroy capability to user documentation
May 4, 2023
b966920
removed trailing whitespace
May 4, 2023
c09c3cf
removed syntax error
May 5, 2023
afaa146
Fix linting / style issues
sbkok May 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ Parameters:
Type: String
Default: "adf-"

ADFTerraformExtension:
Type: "AWS::SSM::Parameter::Value<String>"
Default: /adf/extensions/terraform/enabled

Conditions:
ADFTerraformExtensionEnabled:
!Equals [!Ref ADFTerraformExtension, "True"]

Globals:
Function:
CodeUri: lambda_codebase
Expand Down Expand Up @@ -1458,6 +1466,21 @@ Resources:
RoleArn: !GetAtt PipelineCloudWatchEventRole.Arn
Id: adf-codepipeline-trigger-pipeline

TerraformLockTable:
Condition: ADFTerraformExtensionEnabled
Type: "AWS::DynamoDB::Table"
DeletionPolicy: Retain
UpdateReplacePolicy: Retain
Properties:
AttributeDefinitions:
- AttributeName: LockID
AttributeType: S
KeySchema:
- AttributeName: LockID
KeyType: HASH
BillingMode: PAY_PER_REQUEST
TableName: adf-tflocktable

Outputs:
ADFVersionNumber:
Value: !Ref ADFVersion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ Parameters:

Conditions:
ADFTerraformExtensionEnabled:
Fn::Equals:
- !Ref ADFTerraformExtension
- true
!Equals [!Ref ADFTerraformExtension, "True"]

Resources:
DeploymentFrameworkRegionalS3Bucket:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ tfinit(){
S3_BUCKET_REGION_NAME=$(aws ssm get-parameter --name "/cross_region/s3_regional_bucket/$AWS_REGION" --region "$AWS_DEFAULT_REGION" | jq .Parameter.Value | sed s/\"//g)
mkdir -p "${CURRENT}/tmp/${TF_VAR_TARGET_ACCOUNT_ID}-${AWS_REGION}"
cd "${CURRENT}/tmp/${TF_VAR_TARGET_ACCOUNT_ID}-${AWS_REGION}" || exit
cp -R "$CURRENT/tf/*" "${CURRENT}/tmp/${TF_VAR_TARGET_ACCOUNT_ID}-${AWS_REGION}"
cp -R "${CURRENT}"/tf/* "${CURRENT}/tmp/${TF_VAR_TARGET_ACCOUNT_ID}-${AWS_REGION}"
# if account related variables exist copy the folder in the work directory
if [ -d "$CURRENT/tfvars/$TF_VAR_TARGET_ACCOUNT_ID" ]; then
cp -R "${CURRENT}/tfvars/${TF_VAR_TARGET_ACCOUNT_ID}/*" "${CURRENT}/tmp/${TF_VAR_TARGET_ACCOUNT_ID}-${AWS_REGION}"
if [ -d "${CURRENT}/tfvars/${TF_VAR_TARGET_ACCOUNT_ID}" ]; then
cp -R "${CURRENT}/tfvars/${TF_VAR_TARGET_ACCOUNT_ID}"/* "${CURRENT}/tmp/${TF_VAR_TARGET_ACCOUNT_ID}-${AWS_REGION}"
fi
if [ -f "${CURRENT}/tfvars/global.auto.tfvars" ]; then
cp -R "${CURRENT}/tfvars/global.auto.tfvars" "${CURRENT}/tmp/${TF_VAR_TARGET_ACCOUNT_ID}-${AWS_REGION}"
fi
cp -R "${CURRENT}/tfvars/global.auto.tfvars" "${CURRENT}/tmp/${TF_VAR_TARGET_ACCOUNT_ID}-${AWS_REGION}"
terraform init \
-backend-config "bucket=$S3_BUCKET_REGION_NAME" \
-backend-config "region=$AWS_REGION" \
Expand All @@ -30,7 +32,7 @@ tfinit(){
tfplan(){
DATE=$(date +%Y-%m-%d)
TS=$(date +%Y%m%d%H%M%S)
bash "$CURRENT/adf-build/helpers/sts.sh" "$TF_VAR_TARGET_ACCOUNT_ID" "$TF_VAR_TARGET_ACCOUNT_ROLE"
bash "${CURRENT}/adf-build/helpers/sts.sh" "${TF_VAR_TARGET_ACCOUNT_ID}" "${TF_VAR_TARGET_ACCOUNT_ROLE}"
terraform plan -out "${ADF_PROJECT_NAME}-${TF_VAR_TARGET_ACCOUNT_ID}" 2>&1 | tee -a "${ADF_PROJECT_NAME}-${TF_VAR_TARGET_ACCOUNT_ID}-${TS}.log"
# Save Terraform plan results to the S3 bucket
aws s3 cp "${ADF_PROJECT_NAME}-${TF_VAR_TARGET_ACCOUNT_ID}-${TS}.log" "s3://${S3_BUCKET_REGION_NAME}/${ADF_PROJECT_NAME}/tf-plan/${DATE}/${TF_VAR_TARGET_ACCOUNT_ID}/${ADF_PROJECT_NAME}-${TF_VAR_TARGET_ACCOUNT_ID}-${TS}.log"
Expand Down