Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output-ify JSON use in CreateRoleStack #1325

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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