Skip to content

Commit 78aabbb

Browse files
Frasslershade
authored andcommitted
Output-ify JSON use in CreateRoleStack
1 parent bbf343e commit 78aabbb

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

aws-cs-assume-role/create-role/CreateRoleStack.cs

+6-14
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
using Iam = Pulumi.Aws.Iam;
33
using Log = Pulumi.Log;
44
using System.Collections.Generic;
5-
using System.Text.Json;
6-
using System.Text.Json.Serialization;
75

86
class CreateRoleStack : Stack
97
{
@@ -25,11 +23,8 @@ public CreateRoleStack()
2523
// https://www.pulumi.com/docs/intro/concepts/resources/#additionalsecretoutputs
2624
new CustomResourceOptions { AdditionalSecretOutputs = { "secret" } });
2725

28-
var tempPolicy = unprivilegedUser.Arn.Apply((string arn) =>
29-
{
30-
AssumeRolePolicyArgs policyArgs = new AssumeRolePolicyArgs(arn);
31-
return JsonSerializer.Serialize<AssumeRolePolicyArgs>(policyArgs);
32-
});
26+
AssumeRolePolicyArgs policyArgs = new AssumeRolePolicyArgs(unprivilegedUser.Arn);
27+
var tempPolicy = Output.JsonSerialize<AssumeRolePolicyArgs>(policyArgs);
3328

3429
var allowS3ManagementRole = new Iam.Role("allow-s3-management", new Iam.RoleArgs
3530
{
@@ -63,7 +58,7 @@ public class AssumeRolePolicyArgs
6358
public string Version => "2012-10-17";
6459
public StatementArgs Statement { get; private set; }
6560

66-
public AssumeRolePolicyArgs(string arn)
61+
public AssumeRolePolicyArgs(Input<string> arn)
6762
{
6863
Statement = new StatementArgs(arn);
6964
}
@@ -77,25 +72,22 @@ public class StatementArgs
7772
public PrincipalArgs Principal { get; private set; }
7873
public string Action => "sts:AssumeRole";
7974

80-
public StatementArgs(string arn)
75+
public StatementArgs(Input<string> arn)
8176
{
8277
Principal = new PrincipalArgs(arn);
8378
}
8479
}
8580

8681
public class PrincipalArgs
8782
{
88-
public string AWS { get; private set; }
83+
public Input<string> AWS { get; private set; }
8984

90-
public PrincipalArgs(string arn)
85+
public PrincipalArgs(Input<string> arn)
9186
{
9287
AWS = arn;
9388
}
9489
}
9590

96-
97-
98-
9991
[Output]
10092
public Output<string> roleArn { get; set; }
10193
[Output]

0 commit comments

Comments
 (0)