Skip to content

Commit 207e3db

Browse files
authored
Fix Beanstalk integ by making sure they have the required IAM permissions for the Beanstalk environment. (#886)
1 parent 9f812e9 commit 207e3db

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test/AWS.Deploy.CLI.IntegrationTests/Helpers/IAMHelper.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ public async Task DeleteRoleAndInstanceProfileAfterBeanstalkEnvionmentDeployment
3232
var role = existingRoles.FirstOrDefault(x => string.Equals(roleName, x.RoleName));
3333
if (role != null)
3434
{
35+
var polices = (await _client.ListAttachedRolePoliciesAsync(new ListAttachedRolePoliciesRequest { RoleName = roleName })).AttachedPolicies;
36+
if (polices != null)
37+
{
38+
foreach(var policy in polices)
39+
{
40+
await _client.DetachRolePolicyAsync(new DetachRolePolicyRequest
41+
{
42+
RoleName = roleName,
43+
PolicyArn = policy.PolicyArn
44+
});
45+
}
46+
}
47+
3548
await _client.RemoveRoleFromInstanceProfileAsync(new RemoveRoleFromInstanceProfileRequest
3649
{
3750
RoleName = roleName,
@@ -78,6 +91,12 @@ await _client.CreateRoleAsync(new CreateRoleRequest
7891
AssumeRolePolicyDocument = assumeRolepolicyDocument.Replace("'", "\""),
7992
MaxSessionDuration = 7200
8093
});
94+
95+
await _client.AttachRolePolicyAsync(new AttachRolePolicyRequest
96+
{
97+
RoleName = roleName,
98+
PolicyArn = "arn:aws:iam::aws:policy/AWSElasticBeanstalkWebTier"
99+
});
81100
}
82101

83102
InstanceProfile instanceProfile = null;

0 commit comments

Comments
 (0)