From bb7ed811dd04a8c682251d965b28b0f44787acea Mon Sep 17 00:00:00 2001 From: Fraser Waters Date: Fri, 16 Dec 2022 16:28:50 +0000 Subject: [PATCH] Output-ify JSON use in CreateRoleStack --- .../create-role/CreateRoleStack.cs | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/aws-cs-assume-role/create-role/CreateRoleStack.cs b/aws-cs-assume-role/create-role/CreateRoleStack.cs index bfca4fc3d..e94bf3e17 100644 --- a/aws-cs-assume-role/create-role/CreateRoleStack.cs +++ b/aws-cs-assume-role/create-role/CreateRoleStack.cs @@ -2,8 +2,6 @@ using Iam = Pulumi.Aws.Iam; using Log = Pulumi.Log; using System.Collections.Generic; -using System.Text.Json; -using System.Text.Json.Serialization; class CreateRoleStack : Stack { @@ -25,11 +23,8 @@ public CreateRoleStack() // https://www.pulumi.com/docs/intro/concepts/resources/#additionalsecretoutputs new CustomResourceOptions { AdditionalSecretOutputs = { "secret" } }); - var tempPolicy = unprivilegedUser.Arn.Apply((string arn) => - { - AssumeRolePolicyArgs policyArgs = new AssumeRolePolicyArgs(arn); - return JsonSerializer.Serialize(policyArgs); - }); + AssumeRolePolicyArgs policyArgs = new AssumeRolePolicyArgs(unprivilegedUser.Arn); + var tempPolicy = Output.JsonSerialize(policyArgs); var allowS3ManagementRole = new Iam.Role("allow-s3-management", new Iam.RoleArgs { @@ -63,7 +58,7 @@ public class AssumeRolePolicyArgs public string Version => "2012-10-17"; public StatementArgs Statement { get; private set; } - public AssumeRolePolicyArgs(string arn) + public AssumeRolePolicyArgs(Input arn) { Statement = new StatementArgs(arn); } @@ -77,7 +72,7 @@ public class StatementArgs public PrincipalArgs Principal { get; private set; } public string Action => "sts:AssumeRole"; - public StatementArgs(string arn) + public StatementArgs(Input arn) { Principal = new PrincipalArgs(arn); } @@ -85,17 +80,14 @@ public StatementArgs(string arn) public class PrincipalArgs { - public string AWS { get; private set; } + public Input AWS { get; private set; } - public PrincipalArgs(string arn) + public PrincipalArgs(Input arn) { AWS = arn; } } - - - [Output] public Output roleArn { get; set; } [Output]