I'm trying to invalidate the Cloudfront cache after a build has done and what I get is the following error in Codebuild : [Container] 2022/05/16 15:46:11 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: aws cloudfront create-invalidation --distribution-id myid --paths '/*'. Reason: exit status 254
Here's my BuildSpec definition
version: 0.2
env:
variables:
APP_NAME: "managerui"
phases:
install:
runtime-versions:
nodejs: 14.x
commands:
- echo install process started
- cd src/UI/managerui/
- ls
- npm install && npm install -g @angular/cli
build:
commands:
- echo build process started now
- ls
- ng build --configuration=production
post_build:
commands:
- echo build process finished, we should uplload to S3 now
- ls
- cd dist/
- ls -la
- aws s3 sync . s3://ett-manager-ui --delete
- aws cloudfront create-invalidation --distribution-id=myid--paths '/*
Do you see anything that's wrong?? I've tried running the create-invalidation instruction on my running laptop and it works..
Thanks in advance
#UPDATE
I've resolved... it was a missing permission issue... I've added
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor1",
"Effect": "Allow",
"Action": [
"cloudfront:UpdateDistribution",
"cloudfront:DeleteDistribution",
"cloudfront:CreateInvalidation"
],
"Resource": "arn:aws:cloudfront::<account_id>:distribution/<distribution_id>"
}
]
}
and it works fine.
This can be closed
distribution_id
in thebuildspec.yml
file is the correct one – Lafreniere