Skip to content

Commit 8354d70

Browse files
authored
update vpc-peering with requester params (#1097)
1 parent 4cfa96c commit 8354d70

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

modules/vpc-peering/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,9 @@ atmos terraform apply vpc-peering -s ue1-prod
230230
| <a name="input_regex_replace_chars"></a> [regex\_replace\_chars](#input\_regex\_replace\_chars) | Terraform regular expression (regex) string.<br>Characters matching the regex will be removed from the ID elements.<br>If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no |
231231
| <a name="input_region"></a> [region](#input\_region) | AWS Region | `string` | n/a | yes |
232232
| <a name="input_requester_allow_remote_vpc_dns_resolution"></a> [requester\_allow\_remote\_vpc\_dns\_resolution](#input\_requester\_allow\_remote\_vpc\_dns\_resolution) | Allow requester VPC to resolve public DNS hostnames to private IP addresses when queried from instances in the accepter VPC | `bool` | `true` | no |
233+
| <a name="input_requester_role_arn"></a> [requester\_role\_arn](#input\_requester\_role\_arn) | Requestor AWS assume role ARN, if not provided it will be assumed to be the current terraform role. | `string` | `null` | no |
233234
| <a name="input_requester_vpc_component_name"></a> [requester\_vpc\_component\_name](#input\_requester\_vpc\_component\_name) | Requestor vpc component name | `string` | `"vpc"` | no |
235+
| <a name="input_requester_vpc_id"></a> [requester\_vpc\_id](#input\_requester\_vpc\_id) | Requestor VPC ID, if not provided, it will be looked up by component using variable `requester_vpc_component_name` | `string` | `null` | no |
234236
| <a name="input_stage"></a> [stage](#input\_stage) | ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no |
235237
| <a name="input_tags"></a> [tags](#input\_tags) | Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`).<br>Neither the tag keys nor the tag values will be modified by this module. | `map(string)` | `{}` | no |
236238
| <a name="input_tenant"></a> [tenant](#input\_tenant) | ID element \_(Rarely used, not included by default)\_. A customer identifier, indicating who this instance of a resource is for | `string` | `null` | no |

modules/vpc-peering/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
locals {
22
enabled = module.this.enabled
33

4-
requester_vpc_id = module.requester_vpc.outputs.vpc_id
4+
requester_vpc_id = coalesce(var.requester_vpc_id, module.requester_vpc.outputs.vpc_id)
55

66
accepter_aws_assume_role_arn = var.accepter_stage_name != null ? module.iam_roles.terraform_role_arns[var.accepter_stage_name] : var.accepter_aws_assume_role_arn
77
}
@@ -24,7 +24,7 @@ module "vpc_peering" {
2424
auto_accept = var.auto_accept
2525

2626
requester_allow_remote_vpc_dns_resolution = var.requester_allow_remote_vpc_dns_resolution
27-
requester_aws_assume_role_arn = module.iam_roles.terraform_role_arn
27+
requester_aws_assume_role_arn = coalesce(var.requester_role_arn, module.iam_roles.terraform_role_arn)
2828
requester_region = var.region
2929
requester_vpc_id = local.requester_vpc_id
3030

modules/vpc-peering/variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,18 @@ variable "accepter_stage_name" {
3737
default = null
3838
}
3939

40+
variable "requester_vpc_id" {
41+
type = string
42+
description = "Requestor VPC ID, if not provided, it will be looked up by component using variable `requester_vpc_component_name`"
43+
default = null
44+
}
45+
46+
variable "requester_role_arn" {
47+
type = string
48+
description = "Requestor AWS assume role ARN, if not provided it will be assumed to be the current terraform role."
49+
default = null
50+
}
51+
4052
variable "requester_allow_remote_vpc_dns_resolution" {
4153
type = bool
4254
description = "Allow requester VPC to resolve public DNS hostnames to private IP addresses when queried from instances in the accepter VPC"

0 commit comments

Comments
 (0)