Skip to content

Commit

Permalink
Output-ify JSON use in CreateRoleStack
Browse files Browse the repository at this point in the history
  • Loading branch information
Frassle committed Dec 16, 2022
1 parent 3aab58b commit bb7ed81
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions aws-cs-assume-role/create-role/CreateRoleStack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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<AssumeRolePolicyArgs>(policyArgs);
});
AssumeRolePolicyArgs policyArgs = new AssumeRolePolicyArgs(unprivilegedUser.Arn);
var tempPolicy = Output.JsonSerialize<AssumeRolePolicyArgs>(policyArgs);

var allowS3ManagementRole = new Iam.Role("allow-s3-management", new Iam.RoleArgs
{
Expand Down Expand Up @@ -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<string> arn)
{
Statement = new StatementArgs(arn);
}
Expand All @@ -77,25 +72,22 @@ public class StatementArgs
public PrincipalArgs Principal { get; private set; }
public string Action => "sts:AssumeRole";

public StatementArgs(string arn)
public StatementArgs(Input<string> arn)
{
Principal = new PrincipalArgs(arn);
}
}

public class PrincipalArgs
{
public string AWS { get; private set; }
public Input<string> AWS { get; private set; }

public PrincipalArgs(string arn)
public PrincipalArgs(Input<string> arn)
{
AWS = arn;
}
}




[Output]
public Output<string> roleArn { get; set; }
[Output]
Expand Down

0 comments on commit bb7ed81

Please sign in to comment.