cloudformation-cli icon indicating copy to clipboard operation
cloudformation-cli copied to clipboard

Please add support for standard CLI environment variables

Open kddejong opened this issue 5 years ago • 2 comments

When doing some testing it appears that the cfn command doesn't handle environment variables like AWS_REGION for its commands.

It would be nice to have support for the standard AWS cli configuration items.

kddejong avatar Nov 11 '20 17:11 kddejong

places I could find not using AWS_DEFAULT_REGION: https://github.com/aws-cloudformation/cloudformation-cli/blob/49eac51bf8257b0b2cc63cc26c9338eff592d3e1/src/rpdk/core/test.py#L32

https://github.com/aws-cloudformation/cloudformation-cli/blob/49eac51bf8257b0b2cc63cc26c9338eff592d3e1/src/rpdk/core/fragment/generator.py#L115-L116


similar to https://github.com/aws-cloudformation/cloudformation-cli/issues/557

PatMyron avatar Jan 05 '21 23:01 PatMyron

This is also a problem when using exports/imports in inputs (and took me way to long to figure out):

(I'm using environment variables for access key and secret key, and those are working as expected)

~$ env | grep AWS_REGION
AWS_REGION=eu-west-1

~$ aws cloudformation list-exports --query "Exports[?Name=='AccountAlternateContactCurrentAccountId']"
[
    {
        "ExportingStackId": "arn:aws:cloudformation:eu-west-1:[account id]:stack/setup/5e607c90-887b-11ed-aa5d-02710ba04c51",
        "Name": "AccountAlternateContactCurrentAccountId",
        "Value": "[account id]"
    }
]

~$ cat inputs/inputs_1_create.json
{
    "AccountId": "{{AccountAlternateContactCurrentAccountId}}",
    [...]
}

~$ cfn test
Resource schema is valid.
Override file invalid: {'AccountAlternateContactCurrentAccountId'} are not valid cloudformation exports.No Overrides will be applied
[..]

~$ cfn test --region eu-west-1
Resource schema is valid.
[...]
10 passed, 2 skipped, 12 deselected in 173.68s (0:02:53)

benbridts avatar Jan 06 '23 11:01 benbridts