sparse-intern-71089
06/24/2020, 10:56 PMkind-mechanic-53546
06/24/2020, 10:57 PMOutput<string>
kind-mechanic-53546
06/24/2020, 10:58 PMkind-mechanic-53546
06/24/2020, 10:58 PMconst s3_glue_access_policy_doc = pulumi
.all([json_load_bucket.id, glue_scripts_bucket.id])
.apply(([json_load_bucket_id, glue_scripts_bucket_id]) =>
// S3 json load allow glue access
pulumi.output(
aws.iam.getPolicyDocument({
version: "2012-10-17",
statements: [
{
actions: ["s3:*"],
resources: [
`arn:aws:s3:::${json_load_bucket_id}`,
`arn:aws:s3:::${json_load_bucket_id}/*`,
`arn:aws:s3:::${glue_scripts_bucket_id}`,
`arn:aws:s3:::${glue_scripts_bucket_id}/*`,
],
},
],
})
)
);
kind-mechanic-53546
06/24/2020, 11:01 PMlittle-cartoon-10569
06/24/2020, 11:08 PMgreen-school-95910
06/24/2020, 11:09 PMlittle-cartoon-10569
06/24/2020, 11:13 PMpulumi up
? You can use Output.get()
to get values from an Output during up
.kind-mechanic-53546
06/24/2020, 11:59 PMkind-mechanic-53546
06/25/2020, 12:00 AMkind-mechanic-53546
06/25/2020, 12:01 AMkind-mechanic-53546
06/25/2020, 12:01 AMlittle-cartoon-10569
06/25/2020, 12:04 AMlittle-cartoon-10569
06/25/2020, 12:06 AMlittle-cartoon-10569
06/25/2020, 12:07 AMkind-mechanic-53546
06/25/2020, 12:10 AMresources string[]
, the code I posted above does work, but it is unwieldy to have to do pulumi.all().apply(...) instead of just interpolating the values which I could do if resources
was resources: string[] | Output<string>[]
kind-mechanic-53546
06/25/2020, 12:10 AMkind-mechanic-53546
06/25/2020, 12:12 AMstring[] | Output<string>[]
instead of just string[]
, this is quite possibly a typescript Co/Contra variance thing which I haven't looked at in depthkind-mechanic-53546
06/25/2020, 12:13 AMkind-mechanic-53546
06/25/2020, 12:14 AM(
kind-mechanic-53546
06/25/2020, 12:14 AMgreen-school-95910
06/25/2020, 12:18 AMkind-mechanic-53546
06/25/2020, 12:18 AM.json
to pass to create policy
kind-mechanic-53546
06/25/2020, 12:19 AMconst s3_glue_access_policy = new aws.iam.RolePolicy("s3_glue_access_policy", {
namePrefix: `${namePrefixLower}-s3-glue-access-policy`,
role: glue_role,
policy: s3_glue_access_policy_doc.json,
});
little-cartoon-10569
06/25/2020, 12:19 AMlittle-cartoon-10569
06/25/2020, 12:20 AMkind-mechanic-53546
06/25/2020, 12:21 AMgreen-school-95910
06/25/2020, 12:21 AMkind-mechanic-53546
06/25/2020, 12:21 AMkind-mechanic-53546
06/25/2020, 12:22 AMgreen-school-95910
06/25/2020, 12:27 AMkind-mechanic-53546
06/25/2020, 12:30 AMkind-mechanic-53546
06/25/2020, 12:30 AMkind-mechanic-53546
06/25/2020, 12:31 AMgreen-school-95910
06/25/2020, 12:32 AMgreen-school-95910
06/25/2020, 12:34 AMpulumi up
green-school-95910
06/25/2020, 12:37 AMkind-mechanic-53546
06/25/2020, 12:43 AMgetPolicyDocument
has to have resources: string[]
and not resources: string[] | Output<string>[]
kind-mechanic-53546
06/25/2020, 12:43 AMgreen-school-95910
06/25/2020, 12:48 AMget...
methods are not bound to Pulumi resource graph, they are refreshed every time. To make them run after a particular resource you need apply.
Treat them as any normal function in your code. If you make a function that save a string to a file and run it at the root of you code it will execute even during the preview phase. But if you want to save a resource output to a file you need to apply the output to that function and it will only run if and when that output has datakind-mechanic-53546
06/25/2020, 12:50 AM