Skip to content
Open
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
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ Terraform module to deploy production-ready applications and services on an exis
| <a name="input_create_s3_bucket_for_alb_logging"></a> [create\_s3\_bucket\_for\_alb\_logging](#input\_create\_s3\_bucket\_for\_alb\_logging) | (Optional) Creates S3 bucket for storing ALB Access and Connection Logs. | `bool` | `true` | no |
| <a name="input_default_capacity_providers_strategies"></a> [default\_capacity\_providers\_strategies](#input\_default\_capacity\_providers\_strategies) | (Optional) Set of capacity provider strategies to use by default for the cluster. | `any` | `[]` | no |
| <a name="input_load_balancer"></a> [load\_balancer](#input\_load\_balancer) | Configuration for the Application Load Balancer. | <pre>object({<br/> name = optional(string)<br/> internal = optional(bool, false)<br/> subnets_ids = optional(list(string), [])<br/> security_groups_ids = optional(list(string), [])<br/> preserve_host_header = optional(bool)<br/> enable_deletion_protection = optional(bool, false)<br/> access_logs = optional(any, null)<br/> connection_logs = optional(any, null)<br/> target_groups = optional(any, {})<br/> listeners = optional(any, {})<br/> listener_rules = optional(any, {})<br/> tags = optional(map(string), {})<br/> })</pre> | `{}` | no |
| <a name="input_region"></a> [region](#input\_region) | (Optional) AWS region to create resources in. | `string` | `null` | no |
| <a name="input_route53_assume_role_arn"></a> [route53\_assume\_role\_arn](#input\_route53\_assume\_role\_arn) | (Optional) ARN of the role to assume for Route53 operations. | `string` | `null` | no |
| <a name="input_s3_bucket_force_destroy"></a> [s3\_bucket\_force\_destroy](#input\_s3\_bucket\_force\_destroy) | (Optional, Default:false) Boolean that indicates all objects (including any locked objects) should be deleted from the bucket when the bucket is destroyed so that the bucket can be destroyed without error. | `bool` | `false` | no |
| <a name="input_s3_bucket_name"></a> [s3\_bucket\_name](#input\_s3\_bucket\_name) | (Optional, Forces new resource) Name of the bucket. | `string` | `null` | no |
Expand Down
17 changes: 16 additions & 1 deletion examples/complete/main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
provider "aws" {
region = "ap-south-1"
}
provider "aws" {
alias = "cross_account_provider"
region = var.region

dynamic "assume_role" {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's not have this logic here, keep it simple please

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the example main.tf.
So we have removed the provider code from our modules.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, even with example it should be simpler. This is what others will use as reference.

for_each = var.route53_assume_role_arn != null ? [1] : []
content {
role_arn = var.route53_assume_role_arn
}
}
}

locals {
task_definition_network_mode = "awsvpc"
Expand All @@ -25,6 +36,11 @@ locals {
module "ecs_deployment" {
source = "../../"

providers = {
aws = aws
aws.cross_account_provider = aws.cross_account_provider
}

cluster_name = var.cluster_name
vpc_id = var.vpc_id

Expand Down Expand Up @@ -93,7 +109,6 @@ module "ecs_deployment" {
record_zone_id = data.aws_route53_zone.base_domain.zone_id
}
}
region = var.region
# Cross-account role that ACM module will use for Route53 DNS record creation
route53_assume_role_arn = var.route53_assume_role_arn

Expand Down
2 changes: 2 additions & 0 deletions examples/complete/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,11 @@ variable "domain_name" {
variable "region" {
description = "AWS region to deploy resources"
type = string
default = null
}

variable "route53_assume_role_arn" {
description = "ARN of the cross-account role for Route53 DNS record creation"
type = string
default = null
}
16 changes: 0 additions & 16 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -243,22 +243,6 @@ resource "aws_ecs_task_definition" "this" {
################################################################################
# Amazon Certificates Manager Sub-module
################################################################################
provider "aws" {
region = var.region
}

# Cross-account provider for Route53
provider "aws" {
alias = "cross_account_provider"
region = var.region

dynamic "assume_role" {
for_each = var.route53_assume_role_arn != null ? [1] : []
content {
role_arn = var.route53_assume_role_arn
}
}
}

module "acm" {
source = "./modules/acm"
Expand Down
5 changes: 2 additions & 3 deletions modules/acm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@ This sub-module creates the Amazon-issued certificate for a given domain with `v
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.6.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 6.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | ~> 6.0 |
| <a name="provider_aws.cross_account_provider"></a> [aws.cross\_account\_provider](#provider\_aws.cross\_account\_provider) | ~> 6.0 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | n/a |
| <a name="provider_aws.cross_account_provider"></a> [aws.cross\_account\_provider](#provider\_aws.cross\_account\_provider) | n/a |

## Modules

Expand Down
4 changes: 1 addition & 3 deletions modules/acm/providers.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 6.0"
source = "hashicorp/aws"
configuration_aliases = [
aws,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are giving aws version in root versions file.

aws.cross_account_provider
]
}
Expand Down
6 changes: 0 additions & 6 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,6 @@ variable "acm_certificates" {
default = {}
}

variable "region" {
description = "(Optional) AWS region to create resources in."
type = string
default = null
}

variable "route53_assume_role_arn" {
description = "(Optional) ARN of the role to assume for Route53 operations."
type = string
Expand Down
4 changes: 4 additions & 0 deletions versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ terraform {
aws = {
source = "hashicorp/aws"
version = "~> 6.0"

configuration_aliases = [
aws.cross_account_provider
]
}
}
}