Skip to content

Failing to correctly parse AWS CloudFormation Yaml #22

@godeater

Description

@godeater

Hi there,

I'm struggling to use this module to parse an AWS CloudFormation template. The template is mostly strict YAML, but AWS define some "intrinsic functions" which can appear as tag values with a '!'prefix on the function name, followed by its arguments, e.g.

Content:
  S3Bucket: !Ref SomeS3Bucket

or

OtherContent:
  BucketArn: !Sub '{"NodeJsCfnResponseArn":"${LambdaLayerNodeJsCfnResponse}", "NodeJsSendEmailArn":"${LambdaLayerNodeJsSendEmail}"}'

When I try to convert these templates to a PowerShell object using ConvertFrom-Yaml, the function arguments seem to be present in the resulting object, but the function itself has gone completely. Contrived example below:

AWSTemplateFormatVersion: 2010-09-09
Description: A contrived CloudFormation Template
Resources:
  KmsKeyAlias:
    Type: AWS::KMS::Alias
    Properties:
      AliasName: alias/AKMSKey
      TargetKeyId: !Ref AKMSKey

Now run this through the module:

# $Yaml is content as above
$Template = $Yaml | ConvertFrom-Yaml
$Template.Resources.KmsKeyAlias.Properties

Name                           Value
----                           -----
AliasName                      alias/AKMSKey
TargetKeyId                    AKMSKey

Where really I'd prefer to see:

Name                           Value
----                           -----
AliasName                      alias/AKMSKey
TargetKeyId                    !Ref AKMSKey

I tried looking at your docs on adding custom schemas, and apparently that's over my YAML event horizon, as I couldn't make head or tail of it.

Any pointers?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions