https://pulumi.com logo
Title
p

polite-pillow-78450

10/09/2020, 2:43 PM
I am struggling with using Output in a string used as an input for another resource. I have an Account, whose id I need when creating an IAM policy document:
aws.iam.GroupPolicy(f'assume-{self.nickname.lower()}-{role}-role',
                                    name=f'assume{role}role',
                                    group=group,
                                    policy=account.id.apply(lambda account_id: f'''
{{
  "Version": "2012-10-17",
  "Statement": [
    {{
      "Action": [
        "sts:*"
      ],
      "Resource": "arn:aws:iam::{account_id}:role/{role}",
      "Effect": "Allow"
    }}
  ]
}}'''),
                                    opts=ResourceOptions(depends_on=[account]))
role
is a regular string.
group
is another resource. Thanks in advance!
c

chilly-hairdresser-56259

10/09/2020, 3:36 PM
If you are waiting on two different resources you could do
Pulumi.Output.All(resource1.id, resource2.id).Apply(lambda args: f"""{args[0]]:{args[1]}""")
p

polite-pillow-78450

10/10/2020, 2:59 PM
The
group
is not in the string I am constructing, but it is a parameter to
GroupPolicy
and should be implicitly waited for.