Nelson
Nelson

Reputation: 3232

How to write pseudo parameters in troposphere?

I want to use the pseudo parameter for a TopicConfigurations topics. So that I can allow the selection of a arn. How can I write a pseudo parameter using troposphere?

Topic Configuration: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-notificationconfig-topicconfig.html

Psuedo Parameter: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/pseudo-parameter-reference.html

Upvotes: 0

Views: 1107

Answers (3)

bgdnlp
bgdnlp

Reputation: 1145

Example using Fn::Join, AWS::Region and AWS::AccountId to form an ARN

# Region and AccountId are pseudo parameters
from troposphere import Join, Region, AccountId

cloudwatch_log_arn = Join(
    ":", ["arn", "aws", "logs", Region, AccountId, "log-group", "log-name"]
)

Pseudo parameters are used with the Ref function, but each of them is defined as a separate object in Troposphere:

AccountId = Ref(AWS_ACCOUNT_ID)
NotificationARNs = Ref(AWS_NOTIFICATION_ARNS)
NoValue = Ref(AWS_NO_VALUE)
Partition = Ref(AWS_PARTITION)
Region = Ref(AWS_REGION)
StackId = Ref(AWS_STACK_ID)
StackName = Ref(AWS_STACK_NAME)
URLSuffix = Ref(AWS_URL_SUFFIX)

So they can be imported and used directly, as in the example above.

Upvotes: 0

phobologic
phobologic

Reputation: 434

You would just use the name of the parameter, in a Ref() call, like so:

Ref("AWS::NotificationARNs")

I use that all the time, mostly with "AWS::NoValue" or "AWS::Region" in most of my use cases.

Good luck!

Upvotes: 0

Nelson
Nelson

Reputation: 3232

I think this should be it, from troposphere/init.py:

Ref(AWS_NOTIFICATION_ARNS))

Upvotes: 0

Related Questions