aws-sam-cli icon indicating copy to clipboard operation
aws-sam-cli copied to clipboard

Allow `sam local invoke` to retrieve account id from current logged in session

Open defenderkev opened this issue 1 year ago • 1 comments

Which issue(s) does this change fix? https://github.com/aws/aws-sam-cli/issues/2325 Replaces Pull Request #6568 after feedback from team

Why is this change necessary? Because currently if you have !Sub xxx${AWS::AccountId}xxx in, for example, a layer definition, SAM uses a default substitution which doesn't reference the correct Account ID

How does it address the issue?

During instantiation of the InvokeContext object an attempt is made to retrieve the caller identity from STS. Assuming this succeeds, the account id is put into _global_parameter_overrides. If a token retrieval error occurs, a warning message is printed and the existing default value is used.

What side effects does this change have? None that I can see

Mandatory Checklist PRs will only be reviewed after checklist is complete

[n/a] Add input/output type hints to new functions/methods [n/a ] Write design document if needed (Do I need to write a design document?) Write/update unit tests [n/a] Write/update integration tests [n/a] Write/update functional tests if needed make pr passes [n/a] make update-reproducible-reqs if dependencies were changed Write documentation

  • Not sure where this should be documented. Happy to do so if pointed in the right direction By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

defenderkev avatar May 02 '24 14:05 defenderkev

It looks like the previous CI check failed for linting reasons, can you run make format to automatically fix them?

lucashuy avatar May 24 '24 23:05 lucashuy