Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Replace local-exec sleep with time_sleep #22

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.72.2
rev: v1.74.1
hooks:
- id: terraform_fmt
- id: terraform_validate
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,14 @@ Examples codified under the [`examples`](https://github.com/terraform-aws-module
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.6 |
| <a name="requirement_time"></a> [time](#requirement\_time) | >=0.7.2 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.6 |
| <a name="provider_time"></a> [time](#provider\_time) | >=0.7.2 |

## Modules

Expand All @@ -328,6 +330,7 @@ No modules.
| [aws_iam_role.dms_access_for_endpoint](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
| [aws_iam_role.dms_cloudwatch_logs_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
| [aws_iam_role.dms_vpc_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
| [time_sleep.wait_for_dependency_resources](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource |
| [aws_iam_policy_document.dms_assume_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_iam_policy_document.dms_assume_role_redshift](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |
Expand Down
38 changes: 14 additions & 24 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ data "aws_iam_policy_document" "dms_assume_role_redshift" {
}
}

# Time Sleep
resource "time_sleep" "wait_for_dependency_resources" {
depends_on = [
aws_iam_role.dms_access_for_endpoint,
aws_iam_role.dms_cloudwatch_logs_role,
aws_iam_role.dms_vpc_role
]

create_duration = "10s"
destroy_duration = "10s"
}

# DMS Endpoint
resource "aws_iam_role" "dms_access_for_endpoint" {
count = var.create && var.create_iam_roles ? 1 : 0
Expand All @@ -52,11 +64,6 @@ resource "aws_iam_role" "dms_access_for_endpoint" {
managed_policy_arns = ["arn:${local.partition}:iam::aws:policy/service-role/AmazonDMSRedshiftS3Role"]
force_detach_policies = true

# https://github.com/hashicorp/terraform-provider-aws/issues/11025#issuecomment-660059684
provisioner "local-exec" {
command = "sleep 10"
}

tags = merge(var.tags, var.iam_role_tags)
}

Expand All @@ -71,11 +78,6 @@ resource "aws_iam_role" "dms_cloudwatch_logs_role" {
managed_policy_arns = ["arn:${local.partition}:iam::aws:policy/service-role/AmazonDMSCloudWatchLogsRole"]
force_detach_policies = true

# https://github.com/hashicorp/terraform-provider-aws/issues/11025#issuecomment-660059684
provisioner "local-exec" {
command = "sleep 10"
}

tags = merge(var.tags, var.iam_role_tags)
}

Expand All @@ -90,11 +92,6 @@ resource "aws_iam_role" "dms_vpc_role" {
managed_policy_arns = ["arn:${local.partition}:iam::aws:policy/service-role/AmazonDMSVPCManagementRole"]
force_detach_policies = true

# https://github.com/hashicorp/terraform-provider-aws/issues/11025#issuecomment-660059684
provisioner "local-exec" {
command = "sleep 10"
}

tags = merge(var.tags, var.iam_role_tags)
}

Expand All @@ -111,9 +108,7 @@ resource "aws_dms_replication_subnet_group" "this" {

tags = merge(var.tags, var.repl_subnet_group_tags)

depends_on = [
aws_iam_role.dms_vpc_role
]
depends_on = [time_sleep.wait_for_dependency_resources]
}

################################################################################
Expand Down Expand Up @@ -146,12 +141,7 @@ resource "aws_dms_replication_instance" "this" {
delete = lookup(var.repl_instance_timeouts, "delete", null)
}

# https://github.com/hashicorp/terraform-provider-aws/issues/11025#issuecomment-660059684
depends_on = [
aws_iam_role.dms_access_for_endpoint,
aws_iam_role.dms_cloudwatch_logs_role,
aws_iam_role.dms_vpc_role,
]
depends_on = [time_sleep.wait_for_dependency_resources]
}

################################################################################
Expand Down
4 changes: 4 additions & 0 deletions versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@ terraform {
source = "hashicorp/aws"
version = ">= 4.6"
}
time = {
source = "hashicorp/time"
version = ">=0.7.2"
}
}
}