serverless-application-model icon indicating copy to clipboard operation
serverless-application-model copied to clipboard

Mappings in template do not maintain quotes during package step

Open jolexa opened this issue 9 years ago • 7 comments

Hello, using aws cloudformation package with the following simple snippet results in the loss of quotes which causes a ChangeSet to remain in CREATE_IN_PROGRESS indefinitely in the proper scenerio.

Mappings:
  '1234567890':
    kmskeys:
      'dev': 'arn:aws:kms:us-east-1:1234567890:key/1234567890-abcdefg-1234-1234'
      'test': 'arn:aws:kms:us-east-1:1234567890:key/1234567890-abcdefg-1234-12345'

after the aws cloudformation package step:

Mappings:
  1234567890:
    kmskeys:
      dev: arn:aws:kms:us-east-1:1234567890:key/1234567890-abcdefg-1234-1234
      test: arn:aws:kms:us-east-1:1234567890:key/1234567890-abcdefg-1234-12345

This is a problem because when using the !Ref "AWS::AccountID" function, a string is returned so it will never match the mapping - if you are mapping per AccountID.

Per the docs, if a Mapping is not used, it is an invalid changeset

So, I'm curious if this is a bug. I feel like I should be able to create a Mapping with Account ID's and then reference the AccountID later in a later block and it is currently not possible with aws cloudformation package. Thoughts?

$ aws --version
aws-cli/1.11.47 Python/2.7.10 Darwin/16.0.0 botocore/1.5.10

jolexa avatar Feb 14 '17 19:02 jolexa

Upon further review and testing, this problem ONLY exists if your account id starts with 0.

jolexa avatar Feb 14 '17 20:02 jolexa

Ah interesting. My first guess is that YAML parser/dumper does type conversion which removes types. Need to dig into this further

sanathkr avatar Feb 17 '17 22:02 sanathkr

aws/aws-cli#2556 gives you a workaround. You can use --use-json to dump in JSON instead of YAML. We still have aws/aws-cli#2511 open which will end up quoting every single string in output just to be safe.

Does this solve your problem?

sanathkr avatar Jun 28 '17 08:06 sanathkr

Sure. I've already made a workaround. If you feel it is sufficient to close this, go ahead. Thanks for the response!

jolexa avatar Jul 01 '17 02:07 jolexa

Sounds good.

sanathkr avatar Jul 01 '17 02:07 sanathkr

@jolexa What was your workaround?

judahb avatar Sep 25 '17 23:09 judahb

Using sed in a pre-deployment step. Ugly but quicker than waiting for awscli bugfixes :/

jolexa avatar Sep 26 '17 00:09 jolexa