Summary:
I use local paths to reference code for lambda functions and a state machine in the template.yml
file describing my cloudformation setup. Transforming these to S3 uris with aws cloudformation package
works for the lambda functions, but not the state machine that I'm trying to add to the setup.
Details:
I have a SAM/Cloudformation template, template.yml
, that relies on paths that apply to my local repo to access both lambda functions and state machine setup files.
template.yml:
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31' # specifies that this is a SAM template, will be transformed to CFN on build
Resources:
WriteDataToDb:
Type: AWS::Serverless::Function
Properties:
CodeUri: src <- here
Handler: writer.write_to_db
...
ProcessDataStateMachine:
Type: AWS::Serverless::StateMachine
Properties:
DefinitionSubstitutions:
WriteDataToDbFunctionArn: !GetAtt WriteDataToDb.Arn
DefinitionUri: statemachine/dataprocessor.json <- here
...
I use the aws cloudformation package
command to translate my template.yml file into a pure cloudformation file, packaged.yml, and to store the relevant code in a S3 bucket, deploymentpackages
(dummy name). The references to the lambda functions in packaged.yml have correctly been translated into S3 uris. The uri for the state machine file however, is not converted to an S3 uri but remains as the same local path.
packaged.yml:
...
WriteDataToDb:
Type: AWS::Serverless::Function
Properties:
CodeUri: s3://deploymentpackages/33fc42027aae846c97ca8e13fec1bba7 <- translated
Handler: writer.write_to_db
...
ProcessDataStateMachine:
Type: AWS::Serverless::StateMachine
Properties:
DefinitionSubstitutions:
WriteDataToDbFunctionArn:
Fn::GetAtt:
- WriteDataToDb
- Arn
DefinitionUri: statemachine/dataprocessor.json <- not translated
Then when I try to create a change set from my packaged.yml
file, I get the error 'DefinitionUri' is not a valid S3 Uri of the form 's3://bucket/key'
, which of course makes sense since it isn't.
My repo is organized in the following way:
├── src
│ ├── __init__.py
│ ├── ...
│ └── writer.py
├── statemachine
│ └── dataprocessor.json
├── template.yml
and I have verified that both the src and statemachine folders make it to the deploymentpackages
bucket.
Why would the aws cloudformation package
command work for the lambda uri but not the state machine one?