Skip to content

Commit 4304ec0

Browse files
authored
chore(e2e): Address issue with deleting roles/policies (#5646)
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.
1 parent f7c5567 commit 4304ec0

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
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: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,10 @@ data "aws_iam_policy_document" "vault_profile" {
3636
}
3737

3838
resource "aws_iam_role" "vault_instance_role" {
39-
count = var.deploy ? 1 : 0
40-
name = "vault_instance_role-${random_string.cluster_id.result}"
41-
assume_role_policy = data.aws_iam_policy_document.vault_instance_role.json
39+
count = var.deploy ? 1 : 0
40+
name = "vault_instance_role-${random_string.cluster_id.result}"
41+
assume_role_policy = data.aws_iam_policy_document.vault_instance_role.json
42+
force_detach_policies = true
4243
}
4344

4445
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)