1

I am using AWS SAM for creating some infrastructures. In the below-mentioned template, the role of the state machine is hard coded. Here, say if I want to refer this from another file say config.json. How can I achieve it.?

Resources:
  OcxDataLoadMachine:
    Type: AWS::Serverless::StateMachine
    Properties:
      Name: ocx_data_load_scripts_machine
      DefinitionUri: ./stepfunctions/ocx_data_load_scripts_machine.asl.json
      Role: "arn:aws:iam::875221978636:role/service-role/StepFunctions-postgres_fact_data_load-role-0f4a24d5"

In serverless model these data we referred data using :

${file(./config.json):IAMROLE}

1 Answers1

1

Instead of config.json you can use the samconfig.toml for referring those values. The config can also be overidden with -config-file parameter.

Check the below link for more details.

https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-config.html

Vikram S
  • 792
  • 4
  • 7
  • I plan to maintain names of IAM roles on the file for many resources. How can we refer the value from samconfig.toml into the template.yaml file. Can you share snippet. – Dhivakhar Venkatachalam Jan 11 '23 at 07:43
  • You can use the parameters and then use the parameter references. https://stackoverflow.com/questions/48104665/aws-sam-local-environment-variables – Vikram S Jan 11 '23 at 09:22
  • version=0.1 [default.global.parameters] parameter_overrides=[ "TemplateInput1=Value1", "TemplateInput2=Value2" ] – Vikram S Jan 11 '23 at 09:24