8

Working through a deployment on a stack using AWS SAM and deploying via GitHub actions and was trying to use the Config TOML file and specifying a config environment in the deploy command and I am running into the issue where it seems to be just ignoring what I am specifying in the deployment command. Only thing I can only guess I am doing wrong is that I cannot actually use these or that I have it in the wrong location but I would greatly appreciate any help on the matter. Not finding much out there in terms of similar examples or documentation.

sam deploy --stack-name mySuperAwesomeStuff \
--region ${{ secrets.AWS_REGION }} \
--confirm-changeset \
--config-file ./functions/function1/function1.toml \
--config-env nonprod \
--template-file ./functions/function1/template.yaml

Ideally I would love to get the region out of there and into the TOML file as well as the stackname.

My TOML file looks like this:

[nonprod.deploy.parameters]
stack_name="super-awesome-stack-name"
region="us-east-2"
confirm_changeset=true
cababilities="CABILITIES_IAM"

Once again, just seems to be completely ignoring me trying to use the config-file and I am not sure what I am missing here.

Beefster
  • 723
  • 7
  • 19
OMeThEre
  • 81
  • 1
  • 1
  • 2

4 Answers4

5

i am new to sam cli myself and came across this issue and figured it out about 2minutes ago. it's a bit confusing at first, but you should know that the samconfig.toml file is being read when doing sam deploy, the key thing you're missing is the environment that you want to deploy. in your case, you have named it nonprod([nonprod.deploy.parameters] based on this line). the command you should be running for deployment should now be sam deploy --stack-name super-awesome-stack-name --config-env nonprod.

Dharman
  • 30,962
  • 25
  • 85
  • 135
jsnulla
  • 51
  • 2
  • Yah that is what I have above. --config-file ./functions/function1/function1.toml \ --config-env nonprod \ – OMeThEre Jan 14 '21 at 14:34
1

My samconfig.toml also has a version at the top, like

version = 0.1
[nonprod.deploy.parameters]
region = "us-east-2"

I suspect this is the problem with --config-file attribute. I would suggest to rename the config to samconfig.toml and place it on the root, where you are running sam deploy to pinpoint the problem with --config-file.

Also, I found this which says that, --config-file is not implemented yet

https://github.com/aws/aws-sam-cli/blob/develop/designs/sam-config.md#not-implemented

PS: I have my samconfig.toml on the root where I run sam deploy and it works like a charm.

saurabh_garg
  • 86
  • 1
  • 7
1

What worked for me was specifying the full path to the samconfig.toml (instead of the relative path)

sam deploy --config-file <ABSOLUTE_PATH_TO_CONFIG_FILE> --template-file <RELATIVE_OR_ABSOLUTE_PATH_TO_TEMPLATE_FILE>

And my config file (samconfig.toml)

version = 0.1
[default.deploy.parameters]
stack_name = "xxx"
s3_bucket = "xxx"
s3_prefix = "xxx"
region = "xxx"
confirm_changeset = false
capabilities = "CAPABILITY_IAM"
image_repositories = []
allkenang
  • 1,511
  • 15
  • 12
0

Please check if you have added this header [nonprod.deploy] and then the parameters

[nonprod.deploy]
[nonprod.deploy.parameters]
stack_name="super-awesome-stack-name"
region="us-east-2"
confirm_changeset=true
cababilities="CABILITIES_IAM"
Vinay Kachare
  • 81
  • 1
  • 3