简体   繁体   English

如何在对流层中编写伪参数?

[英]How to write pseudo parameters in troposphere?

I want to use the pseudo parameter for a TopicConfigurations topics.我想对 TopicConfigurations 主题使用伪参数。 So that I can allow the selection of a arn.这样我就可以允许选择 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主题配置: 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伪参数: http ://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/pseudo-parameter-reference.html

我认为这应该是它,来自对流层/ init .py:

Ref(AWS_NOTIFICATION_ARNS))

You would just use the name of the parameter, in a Ref() call, like so:您只需在 Ref() 调用中使用参数名称,如下所示:

Ref("AWS::NotificationARNs")

I use that all the time, mostly with "AWS::NoValue" or "AWS::Region" in most of my use cases.我一直使用它,在我的大多数用例中主要使用“AWS::NoValue”或“AWS::Region”。

Good luck!祝你好运!

Example using Fn::Join, AWS::Region and AWS::AccountId to form an ARN使用 Fn::Join、AWS::Region 和 AWS::AccountId 形成 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 :伪参数与 Ref 函数一起使用,但它们中的每一个都被定义为对流层中的一个单独对象:

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.因此它们可以直接导入和使用,如上例所示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM