Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help with Intrinsic functions #394

Open
jbieberly-xumo opened this issue Dec 16, 2024 · 5 comments · May be fixed by #399
Open

Help with Intrinsic functions #394

jbieberly-xumo opened this issue Dec 16, 2024 · 5 comments · May be fixed by #399
Assignees

Comments

@jbieberly-xumo
Copy link

jbieberly-xumo commented Dec 16, 2024

I am attempting to build a test template for a CloudFormation template that uses intrinsic functions to use values returned after resources are created to populate values needed for other resources in the same template. Here is what this part of my CloudFormation template looks like:
- Name: ENDPOINT_MPV2_2 Value: !Select [0, !GetAtt MediaPackageV2Channel.IngestEndpointUrls] - Name: ENDPOINT_MPV2_1 Value: !Select [1, !GetAtt MediaPackageV2Channel.IngestEndpointUrls]

This functionality works fine and the correct values get populated when I build a CloudFormation stack.

I've tried several methods to mock these URL values, none have been successful. I typically get an error like one of these, depending on what I try:
Error: IngestEndpointUrls property is missing from MediaPackageV2Channel resource.
Error: Fn::Select - The first value must be a Number and the second a List.

The failure always occurs at template.create_stack when running the test function.

Is there some documentation I should be referencing to figure this out? An example would be great!

@dhutchison
Copy link
Collaborator

Hey @jbieberly-xumo,

My best guess right now is that it isn't necessarily something you are doing wrong, but possibly an edge case either with ordering of intrinsic functions or how rendering of the AWS::MediaPackageV2::Channel type happens.

Would you be able to provide a bit more of the template, including the two involved resources so I can troubleshoot a bit better?

Thanks.

@jbieberly-xumo
Copy link
Author

jbieberly-xumo commented Dec 17, 2024

Here is the template portion that creates AWS::MediaPackageV2::Channel

MediaPackageV2Channel: Type: AWS::MediaPackageV2::Channel Properties: ChannelGroupName: dev_video_1 ChannelName: !Sub ${AWS::StackName}-MediaPackageChannel

As you can see, it is very basic, but the IngestEndpointUrls are returned after the channel is created. Then they can be accessed with this: Value: !Select [0, !GetAtt MediaPackageV2Channel.IngestEndpointUrls]

So I need a way to mock that value, since with cloud_radar it isn't actually creating the MediaPackageV2Channel and no URL would be returned.

I'm accessing the IngestEndpointUrls twice, once when I create an ECS task definition and once in the output of the CF stack. The ECS task definition has a bunch of stuff I probably shouldn't share, but the output looks like this:
Outputs: ClusterName: Description: The cluster used to create the service. Value: !Ref ECSClusterName ECSService: Description: The created service. Value: !Ref ECSService ChannelArn: Description: The ARN of the MediaPackageV2 Channel. Value: !GetAtt MediaPackageV2Channel.Arn ChannelCreatedAt: Description: The creation timestamp of the MediaPackageV2 Channel. Value: !GetAtt MediaPackageV2Channel.CreatedAt ChannelIngestEndpointUrl1: Description: The first IngestEndpointUrl of the MediaPackageV2 Channel. Value: !Select [0, !GetAtt MediaPackageV2Channel.IngestEndpointUrls] ChannelIngestEndpointUrl2: Description: The second IngestEndpointUrl of the MediaPackageV2 Channel. Value: !Select [1, !GetAtt MediaPackageV2Channel.IngestEndpointUrls]

@dhutchison
Copy link
Collaborator

Thanks for that - it'll help diagnose things a bit better.

Probably won't be till next week though until I can get a look at it. Got a crazy amount of things to get done this week.

@dhutchison
Copy link
Collaborator

So the quick (and minimal) investigation I've done in to this today is that the GetAtt implementation in this library is a bit simplistic. What it returns is the string of {resource_name}.{att_name} - e.g. MediaPackageV2Channel.IngestEndpointUrls.

This is not doing any real rendering of what return values for CloudFormation resources could look like. For things that take strings the current implementation is good enough, it just falls down where other intrinsic functions are stacked.

Will swing back around in a few days and see if there are any reasonable solutions to make this work. I don't think we want to be in the position where we are adding to the library special cases for each resource type and consumers need to wait for new types to be supported, but then again do need some way to support it in these edge cases. I don't think I've came across many resource types that return list values.

@dhutchison
Copy link
Collaborator

The linked PR #399 contains a proposed solution to this edge case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants