0

How come the intrinsic cloudformation function !ImportValue does not resolve to a string when I place it in a Join function within the definitionbody of my serverless api template?

This cloudformation template:

  UserAPI:
    Type: 'AWS::Serverless::Api'
    Properties:
      StageName: !ImportValue StageName
      DefinitionBody:
          'Fn::Transform':
            Name: 'AWS::Include'
            Parameters:
              Location: !Join [ "", [ "s3://", !ImportValue S3APIBucket, "/api_user.yaml" ] ]

Will generate the following error:

Failed to create the changeset: Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state Status: FAILED. Reason: The value of parameter Location under transform Include must resolve to a string, number, boolean or a list of any of these.

However, if I replace the last line with:

Location: !Join [ "", [ "s3://", !Ref S3APIBucket, "/api_user.yaml" ] ]

And have S3APIBucket as a parameter it works fine. Or otherwise don't use !Join and just hardcode the s3 bucket name, that also works fine.

Ludo
  • 2,307
  • 2
  • 27
  • 58
  • Are you sure `S3APIBucket` has the name of the exported resource? – yorodm Sep 13 '18 at 18:46
  • can you try using multi line like this example https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-applicationautoscaling-scalabletarget.html? I followed this link and everything works just fine for me. – sayboras Sep 14 '18 at 06:41
  • @yorodm Yes, certain. – Ludo Sep 14 '18 at 09:10
  • @Apolozeus what example are you referring to? There are no uses of !ImportValue in any of the examples. I had tried putting on multi-line as well rather than the shorthand syntax as well–no success. I believe the problem lies in the use of importvalue and it operating in a different way then !Ref...? – Ludo Sep 14 '18 at 09:11
  • I used the same one for !Join and !Ref in the above link. – sayboras Sep 14 '18 at 09:47
  • This issue is still unresolved... The problem resides in the use of !ImportValue rather than !Ref – Ludo Sep 23 '18 at 11:19

0 Answers0