-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: Add region config to default.global.parameters
#7841
Comments
Thanks for reaching out. Currently the region is read from the |
My pleasure. During Setting default arguments for 'sam deploy'
=========================================
Stack Name [test]:
AWS Region [eu-west-1]:
#Shows you resources changes to be deployed and require a 'Y' to initiate deploy
Confirm changes before deploy [Y/n]:
#SAM needs permission to be able to create roles to connect to the resources in your template
Allow SAM CLI IAM role creation [Y/n]:
#Preserves the state of previously provisioned resources when an operation fails
Disable rollback [y/N]:
HelloWorldFunction has no authentication. Is this okay? [y/N]: y
Save arguments to configuration file [Y/n]:
SAM configuration file [samconfig.toml]:
SAM configuration environment [default]: This produces the below config: # More information about the configuration file can be found here:
# https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-config.html
version = 0.1
[default.global.parameters]
stack_name = "test"
[default.build.parameters]
cached = true
parallel = true
[default.validate.parameters]
lint = true
[default.deploy.parameters]
capabilities = "CAPABILITY_IAM"
confirm_changeset = true
resolve_s3 = true
s3_prefix = "test"
region = "eu-west-1"
image_repositories = []
[default.package.parameters]
resolve_s3 = true
[default.sync.parameters]
watch = true
[default.local_start_api.parameters]
warm_containers = "EAGER"
[default.local_start_lambda.parameters]
warm_containers = "EAGER" The region is specified in This is not a desired behaviour. Given me limited exposure to building CLIs with Click, I can't really identify where in the source code the samconfig is generated, and where a deploy with the |
Thank you for explaining that distinction. I understand now that SAM CLI handles region settings differently between sync and deploy commands. For sync operations, it defaults to the region specified under [default.sync.parameters] in the configuration, like:
This raises an interesting design question: When a region is specified in either sync or deploy commands, should SAM CLI automatically apply that region setting to both operations? We could approach this in two ways:
For automatic option, It would represent a significant change to SAM CLI's existing behavior. Currently, users can maintain different region settings for different purposes - for example:
If we automatically propagated region settings, it could lead to unexpected behavior. A user might suddenly find their sync targeting a different region than intended, simply because they performed a deploy to another region. Therefore, I lean towards the optional approach using a flag like |
I understand what you mean but I believe there's still an avenue for the automatic approach. We don't have to change how the SAM CLI determines what region to use - i.e if region only is specified under deployment parameters, then continue using the default in the
[default.sync.parameters]
watch = true
region = "us-east-2" <--- Or [default.global.parameters]
stack_name = "test"
region = "us-east-2" <--- Neither option would impact existing deployment flows if I'm not mistaken, since we're not updating the CLIs behaviour, only the In general, my opinion is that choosing to persist the parameters you've specified through the "wizard" should apply equally to all parameters. As part of the "wizard" we specify stack name, which is added as a global parameter. Why should the same logic not be applied to region? The automatic approach would not impact any existing deployments as far as I understand. |
Understood, if this is the behavior coming from |
Describe your idea/feature/enhancement
I wish SAM CLI would add the region configuration to
default.global.parameters
in thesamconfig.toml
.Currently, when using
sam init´ the samconfig is generated based on the user input, and the only property in
default.global.parametersis the stack_name. The region parameter is added under
default.deploy.parameterswhich means that all
sam deploycommands will use the specified region. However,
sam sync` uses the default region in the local installation of the AWS CLI configuration, which causes a lot of misstakes and deployments to the wrong region.Proposal
Add region to
default.global.parameters
to ensure all deployment usingsam sync
use the same configured region.Things to consider:
No.
Additional Details
The text was updated successfully, but these errors were encountered: