The AWS Deployment Framework (ADF) is an extensive and flexible framework to manage and deploy resources across multiple AWS accounts and regions based on AWS Organizations.
Apache License 2.0
668
stars
226
forks
source link
AWS CodeBuild error: 'list' object has no attribute 'get' #692
I'm encountering an issue while deploying with AWS CodeBuild and AWS Deployment Framework (ADF). The deployment process fails with the following error message:
This error occurs within the deploy.sh script, specifically in the line where I fetch the S3 bucket name using the AWS Systems Manager (SSM) get-parameters command.
Here's a simplified version of my deploy.sh script:
#!/bin/bash
echo "Determining regions to prepare"
app_regions=$(aws ssm get-parameters --names /deployment/$ADF_DEPLOYMENT_MAP_SOURCE/$ADF_PROJECT_NAME/regions --with-decryption --output=text --query='Parameters[0].Value')
regions=$(echo $app_regions | sed -e 's/\[\([^]]*\)\]/\1/g' | sed 's/,/ /g' | sed "s/'//g")
for region in $regions
do
echo "Packaging templates for region $region"
ssm_bucket_name="/cross_region/s3_regional_bucket/$region"
bucket=$(aws ssm get-parameters --names $ssm_bucket_name --with-decryption --output=text --query='Parameters[0].Value')
echo "Bucket: $bucket"
# Upload nested templates to S3
aws s3 cp nested_cloudtrail_filter_template.yml s3://$bucket/
aws s3 cp nested_cloudtrail_permission_template.yml s3://$bucket/
# Update CloudFormation template to use S3 URLs
sed -i "s|nested_cloudtrail_filter_template.yml|https://$bucket.s3.amazonaws.com/nested_cloudtrail_filter_template.yml|g" template_$region.yml
sed -i "s|nested_cloudtrail_permission_template.yml|https://$bucket.s3.amazonaws.com/nested_cloudtrail_permission_template.yml|g" template_$region.yml
# Package main template
aws cloudformation package --s3-bucket $bucket --output-template-file $CODEBUILD_SRC_DIR/template_$region.yml --region $region --template-file $CODEBUILD_SRC_DIR/template.yml
echo "Packaging complete for region $region"
echo "Template: $CODEBUILD_SRC_DIR/template_$region.yml"
done
And here's the error output I'm seeing in CodeBuild:
Packaging templates for region eu-north-1
Bucket: adf-global-base-deployment-pipelinebucket-wy5hi2yi7zog
... (output truncated for brevity)
Unable to upload artifact nested_cloudtrail_filter_template.yml referenced by TemplateURL parameter of nestedCloudTrailFilter resource.
'list' object has no attribute 'get'
Packaging complete for region eu-north-1
Template: /codebuild/output/src2263745840/src/template_eu-north-1.yml
Additionally, this is my template.yml:
AWSTemplateFormatVersion: '2010-09-09'
Parameters:
pAccountIds1:
Description: First 100 list of member account ids to grant CloudTrail log access.
Type: String
Default: ''
Outputs:
Main:
Description: Cloudtrail filter for the first 100 member accounts.
Value: !Ref pAccountIds1
Resources:
nestedCloudTrailFilter:
Type: AWS::CloudFormation::Stack
Properties:
Parameters:
pAccountIds1: !Ref pAccountIds1
TemplateURL: nested_cloudtrail_filter_template.yml
nestedCloudTrailPermission:
Type: AWS::CloudFormation::Stack
Properties:
Parameters:
pAccountIds1: !Ref pAccountIds1
TemplateURL: nested_cloudtrail_permission_template.yml
I suspect that the bucket variable might be a list instead of a dictionary, leading to the error when trying to access its get method.
Could someone please help me understand why this error is happening and how to fix it? Any insights or suggestions would be greatly appreciated. Thank you!
I'm encountering an issue while deploying with AWS CodeBuild and AWS Deployment Framework (ADF). The deployment process fails with the following error message:
This is my directory tree:
This error occurs within the
deploy.sh
script, specifically in the line where I fetch the S3 bucket name using the AWS Systems Manager (SSM)get-parameters
command.Here's a simplified version of my
deploy.sh
script:And here's the error output I'm seeing in CodeBuild:
Additionally, this is my
template.yml
:I suspect that the
bucket
variable might be a list instead of a dictionary, leading to the error when trying to access itsget
method.Could someone please help me understand why this error is happening and how to fix it? Any insights or suggestions would be greatly appreciated. Thank you!