Skip to content

Commit c2b6c57

Browse files
chore(e2e): Address issue with deleting roles/policies (#5646) (#5648)
On destroy, there was an issue with deleting IAM roles due to the following error: DeleteConflict: Cannot delete entity, must detach all policies first This commit adds an option to force the policy detachment, preventing the error. (cherry picked from commit 4304ec0) # Conflicts: # enos/modules/aws_vault/iam.tf Co-authored-by: Michael Li <[email protected]>
1 parent f9a59c1 commit c2b6c57

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

enos/modules/aws_boundary/iam.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ data "aws_iam_policy_document" "boundary_profile" {
3232
}
3333

3434
resource "aws_iam_role" "boundary_instance_role" {
35-
name = "boundary_instance_role-${random_string.cluster_id.result}"
36-
assume_role_policy = data.aws_iam_policy_document.boundary_instance_role.json
35+
name = "boundary_instance_role-${random_string.cluster_id.result}"
36+
assume_role_policy = data.aws_iam_policy_document.boundary_instance_role.json
37+
force_detach_policies = true
3738
}
3839

3940
resource "aws_iam_instance_profile" "boundary_profile" {

enos/modules/aws_vault/iam.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ data "aws_iam_policy_document" "vault_profile" {
3636
}
3737

3838
resource "aws_iam_role" "vault_instance_role" {
39-
name = "vault_instance_role-${random_string.cluster_id.result}"
40-
assume_role_policy = data.aws_iam_policy_document.vault_instance_role.json
39+
name = "vault_instance_role-${random_string.cluster_id.result}"
40+
assume_role_policy = data.aws_iam_policy_document.vault_instance_role.json
41+
force_detach_policies = true
4142
}
4243

4344
resource "aws_iam_instance_profile" "vault_profile" {

enos/modules/aws_worker/iam.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ data "aws_iam_policy_document" "combined_policy_document" {
5858
}
5959

6060
resource "aws_iam_role" "boundary_instance_role" {
61-
name = "boundary_instance_role-${random_string.cluster_id.result}"
62-
assume_role_policy = data.aws_iam_policy_document.boundary_instance_role.json
61+
name = "boundary_instance_role-${random_string.cluster_id.result}"
62+
assume_role_policy = data.aws_iam_policy_document.boundary_instance_role.json
63+
force_detach_policies = true
6364
}
6465

6566
resource "aws_iam_instance_profile" "boundary_profile" {

0 commit comments

Comments
 (0)