@@ -26,12 +26,32 @@ public CreateRoleStack()
26
26
new CustomResourceOptions { AdditionalSecretOutputs = { "secret" } } ) ;
27
27
28
28
AssumeRolePolicyArgs policyArgs = new AssumeRolePolicyArgs ( unprivilegedUser . Arn ) ;
29
- var tempPolicy = Output . Create ( policyArgs ) . Apply ( args => JsonSerializer . Serialize ( args ) ) ;
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
+ }}" ) ;
30
50
31
51
var allowS3ManagementRole = new Iam . Role ( "allow-s3-management" , new Iam . RoleArgs
32
52
{
33
53
Description = "Allow management of S3 buckets" ,
34
- AssumeRolePolicy = tempPolicy
54
+ AssumeRolePolicy = directPolicy // Use the direct string approach instead
35
55
} ) ;
36
56
37
57
var rolePolicy = new Iam . RolePolicy ( "allow-s3-management-policy" , new Iam . RolePolicyArgs
@@ -57,21 +77,30 @@ public CreateRoleStack()
57
77
58
78
public class AssumeRolePolicyArgs
59
79
{
80
+ [ JsonPropertyName ( "Version" ) ]
60
81
public string Version => "2012-10-17" ;
61
- public StatementArgs Statement { get ; private set ; }
82
+
83
+ [ JsonPropertyName ( "Statement" ) ]
84
+ public StatementArgs [ ] Statement { get ; private set ; }
62
85
63
86
public AssumeRolePolicyArgs ( Input < string > arn )
64
87
{
65
- Statement = new StatementArgs ( arn ) ;
88
+ Statement = new StatementArgs [ ] { new StatementArgs ( arn ) } ;
66
89
}
67
-
68
90
}
69
91
70
92
public class StatementArgs
71
93
{
94
+ [ JsonPropertyName ( "Sid" ) ]
72
95
public string Sid => "AllowAssumeRole" ;
96
+
97
+ [ JsonPropertyName ( "Effect" ) ]
73
98
public string Effect => "Allow" ;
99
+
100
+ [ JsonPropertyName ( "Principal" ) ]
74
101
public PrincipalArgs Principal { get ; private set ; }
102
+
103
+ [ JsonPropertyName ( "Action" ) ]
75
104
public string Action => "sts:AssumeRole" ;
76
105
77
106
public StatementArgs ( Input < string > arn )
@@ -82,6 +111,7 @@ public StatementArgs(Input<string> arn)
82
111
83
112
public class PrincipalArgs
84
113
{
114
+ [ JsonPropertyName ( "AWS" ) ]
85
115
public Input < string > AWS { get ; private set ; }
86
116
87
117
public PrincipalArgs ( Input < string > arn )
0 commit comments