Referencing the AWS account id in a troposphere stack

799 views
Skip to first unread message

DP

unread,
Oct 3, 2017, 12:03:16 PM10/3/17
to cloudtools-dev
Hi, 

When trying to reference an AWS account id (can't find a constant for it):

iam.ARN(account=Ref("AWS::AccountId"), resource="root"),

When I generate the template I get: 

"arn:aws:iam::<troposphere.Ref object at 0x7f5de89a4f50>:root"

Does anyone know how I can get the account id?

Thanks!

Michael Barrett

unread,
Oct 3, 2017, 3:44:23 PM10/3/17
to DP, cloudtools-dev
You should use Join() or Sub() to manually build the arn.  In a private project at my work, we use this to build the ARN for a bucket no matter whether a Ref or string is given:


--
You received this message because you are subscribed to the Google Groups "cloudtools-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloudtools-de...@googlegroups.com.
To post to this group, send email to cloudto...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cloudtools-dev/cb86b195-5840-42bc-9d98-2447a404b3da%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael Barrett

unread,
Oct 3, 2017, 3:46:54 PM10/3/17
to DP, cloudtools-dev
BTW, rather than using Ref() for the common constants, these exist in troposphere as well:

https://github.com/cloudtools/troposphere/blob/master/troposphere/__init__.py#L469
Reply all
Reply to author
Forward
0 new messages