@@ -25,16 +25,33 @@ public CreateRoleStack()
25
25
// https://www.pulumi.com/docs/intro/concepts/resources/#additionalsecretoutputs
26
26
new CustomResourceOptions { AdditionalSecretOutputs = { "secret" } } ) ;
27
27
28
- var tempPolicy = unprivilegedUser . Arn . Apply ( ( string arn ) =>
29
- {
30
- AssumeRolePolicyArgs policyArgs = new AssumeRolePolicyArgs ( arn ) ;
31
- return JsonSerializer . Serialize < AssumeRolePolicyArgs > ( policyArgs ) ;
32
- } ) ;
28
+ AssumeRolePolicyArgs policyArgs = new AssumeRolePolicyArgs ( unprivilegedUser . Arn ) ;
29
+ var tempPolicy = Output . Create ( policyArgs ) . Apply ( args => JsonSerializer . Serialize ( args ,
30
+ new JsonSerializerOptions
31
+ {
32
+ WriteIndented = false ,
33
+ PropertyNamingPolicy = null // Remove camelCase policy
34
+ } ) ) ;
35
+
36
+ // Alternative approach using a direct string-based policy document
37
+ var directPolicy = unprivilegedUser . Arn . Apply ( arn => @$ "{{
38
+ ""Version"": ""2012-10-17"",
39
+ ""Statement"": [
40
+ {{
41
+ ""Sid"": ""AllowAssumeRole"",
42
+ ""Effect"": ""Allow"",
43
+ ""Principal"": {{
44
+ ""AWS"": ""{ arn } ""
45
+ }},
46
+ ""Action"": ""sts:AssumeRole""
47
+ }}
48
+ ]
49
+ }}" ) ;
33
50
34
51
var allowS3ManagementRole = new Iam . Role ( "allow-s3-management" , new Iam . RoleArgs
35
52
{
36
53
Description = "Allow management of S3 buckets" ,
37
- AssumeRolePolicy = tempPolicy
54
+ AssumeRolePolicy = directPolicy // Use the direct string approach instead
38
55
} ) ;
39
56
40
57
var rolePolicy = new Iam . RolePolicy ( "allow-s3-management-policy" , new Iam . RolePolicyArgs
@@ -60,42 +77,49 @@ public CreateRoleStack()
60
77
61
78
public class AssumeRolePolicyArgs
62
79
{
80
+ [ JsonPropertyName ( "Version" ) ]
63
81
public string Version => "2012-10-17" ;
64
- public StatementArgs Statement { get ; private set ; }
65
82
66
- public AssumeRolePolicyArgs ( string arn )
83
+ [ JsonPropertyName ( "Statement" ) ]
84
+ public StatementArgs [ ] Statement { get ; private set ; }
85
+
86
+ public AssumeRolePolicyArgs ( Input < string > arn )
67
87
{
68
- Statement = new StatementArgs ( arn ) ;
88
+ Statement = new StatementArgs [ ] { new StatementArgs ( arn ) } ;
69
89
}
70
-
71
90
}
72
91
73
92
public class StatementArgs
74
93
{
94
+ [ JsonPropertyName ( "Sid" ) ]
75
95
public string Sid => "AllowAssumeRole" ;
96
+
97
+ [ JsonPropertyName ( "Effect" ) ]
76
98
public string Effect => "Allow" ;
99
+
100
+ [ JsonPropertyName ( "Principal" ) ]
77
101
public PrincipalArgs Principal { get ; private set ; }
102
+
103
+ [ JsonPropertyName ( "Action" ) ]
78
104
public string Action => "sts:AssumeRole" ;
79
105
80
- public StatementArgs ( string arn )
106
+ public StatementArgs ( Input < string > arn )
81
107
{
82
108
Principal = new PrincipalArgs ( arn ) ;
83
109
}
84
110
}
85
111
86
112
public class PrincipalArgs
87
113
{
88
- public string AWS { get ; private set ; }
114
+ [ JsonPropertyName ( "AWS" ) ]
115
+ public Input < string > AWS { get ; private set ; }
89
116
90
- public PrincipalArgs ( string arn )
117
+ public PrincipalArgs ( Input < string > arn )
91
118
{
92
119
AWS = arn ;
93
120
}
94
121
}
95
122
96
-
97
-
98
-
99
123
[ Output ]
100
124
public Output < string > roleArn { get ; set ; }
101
125
[ Output ]
0 commit comments