The artefact that I create and deploy has a version number in it. It is of the form:
universe-0.0.1-SNAPSHOT.zip
where the 0.0.1-SNAPSHOT is the version.
Now the CloudFormation template has the Handler mapped through a Fn::Join function:
UFunctionCelestial:
Type: AWS::Lambda::Function
Properties:
Code:
S3Bucket: !Ref ArtefactRepositoryBucket
S3Key: !Join [ '', [!Sub '${AWS::StackName}-', !Ref CodeVersion, '.zip' ] ]
Handler: !Join [ '', [!Sub '${AWS::StackName}-', !Ref CodeVersion, '/src/lambdas/celestial_persist_function.handler'] ]
Role: !GetAtt [ UIAMRoleFunctionServiceRoleCelestial, Arn ]
Runtime: python3.7
Environment:
Variables:
CELESTIAL_TABLE_NAME: !Ref UTableCelestial
PRIMARY_KEY: id
DependsOn:
- UIAMRoleFunctionServiceRolePolicyCelestial
- UIAMRoleFunctionServiceRoleCelestial
...SNIP...
Parameters:
ArtefactRepositoryBucket:
Type: String
Description: S3 bucket for asset "foundry-cdk/CelestialHandler/Code"
CodeVersion:
Type: String
Description: S3 key for asset version "foundry-cdk/CelestialHandler/Code"
I guess most of this is irrelevant, except the Handler property
Now the !Ref CodeVersion code version for that line seems to evaluate as 0/0/1-SNAPSHOT for some reason, even though I call this template with the command:
aws2 cloudformation deploy \
--template-file ${CF_TEMPLATE_FILE} \
--region ${ACCOUNT_REGION} \
--stack-name ${PROJECT_NAME} \
--force-upload \
--capabilities CAPABILITY_IAM \
--parameter-overrides \
ArtefactRepositoryBucket=${S3_AWS_RELEASES_BUCKET} \
CodeVersion=${APPLICATION_VERSION}
I echoed out the ${APPLICATION_VERSION} and, yep, it evaluates to 0.0.1-SNAPSHOT
and yet when I go to the console and look at my Lambda I get the message:
Lambda can't find the file universe-0/0/1-SNAPSHOT/src/lambdas/celestial_persist_function.py. Make sure that your handler upholds the format: file-name.method.
So my question is, why is CloudFormation turning my dots into slashes and giving the Lambda a bum reference?
${APPLICATION_VERSION}double quoted and ${S3_AWS_RELEASES_BUCKET} not double quoted, when I saw this error, I removed the double quotes as one of my early tries at fixing this. The quoting (or not quoting) ended up making no difference. - Michael Coxon