0

I have a cloud formation template that I want to import some values from another template. Currently the other template exports a string by joining together an array (better way of doing this?).

In my template I want to import into I am getting the below error when trying to update my stack in the AWS console.

Template format error: YAML not well-formed. (line 71, column 28)

Here is lines 70 and 71 from my YAML file

SubnetId: 
        Fn::Select [ "0", [ Fn::Split: [ ",", Fn::ImportValue [ !Sub "${ExportPrefix}-SubNets"] ] ] ]

Have also tried this..

Fn::Select [ "0", [ {Fn::Split: [ ",", Fn::ImportValue [ {Fn::Sub "${ExportPrefix}-SubNets"}] ]} ] ]

I have checked and all spaces should be spaces and all tabs be tabs.

1

The split function returns a list of strings. I believe encapsulating the function in a list is what is giving you the error. Have you tried removing the brackets around the split function? Something like:

!Select [ "0",  !Split [ "," , !ImportValue [ !Sub "${ExportPrefix}-SubNets" ] ] ]
1
  • Trying that doesn't seem to work, it gives the below error message. I also tried by switching to long form Fn:: compared to ! that passed validation but it didn't deploy. Ran into where it just said it couldn't find the subnet with the full string/line Error message when using your suggesting without modification: Template error: the attribute in Fn::ImportValue must be a string or a function that returns a string – joshk132 Oct 24 '19 at 12:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.