Skip to content

Commit

Permalink
Update build.pkr.hcl to include AWS ECR repository information
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Arnold committed Aug 26, 2024
1 parent 81c9f61 commit 5055753
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions build.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,18 @@ build {
login_server = "${local.aws_account_id}.dkr.ecr.${local.aws_region}.amazonaws.com"
}
}

# Post-processor to write the build name to a file and print the AMI ID
post-processor "manifest" {
output = "ami_id.json"
strip_path = true
}

post-processor "shell-local" {
inline = [
"cat ami_id.json",
"cat ami_id.json | jq -r '.builds[0].artifact_id' > ami_id.txt",
"aws ssm put-parameter --name '/image-pipeline/${var.project_name}/image_id' --type 'String' --value $(cat ami_id.json | jq -r '.builds[0].artifact_id' | awk -F: '{ print $NF }') --overwrite"
]
}
}

0 comments on commit 5055753

Please sign in to comment.