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

Remove provider config #49

Closed
wants to merge 14 commits into from
28 changes: 8 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,20 @@ module "vpc_peering_cross_account" {
stage = "dev"
name = "cluster"

requester_aws_assume_role_arn = "arn:aws:iam::XXXXXXXX:role/cross-account-vpc-peering-test"
requester_region = "us-west-2"
requester_vpc_id = "vpc-xxxxxxxx"
requester_allow_remote_vpc_dns_resolution = true

accepter_aws_assume_role_arn = "arn:aws:iam::YYYYYYYY:role/cross-account-vpc-peering-test"
accepter_region = "us-east-1"
accepter_vpc_id = "vpc-yyyyyyyy"
accepter_allow_remote_vpc_dns_resolution = true

providers = {
aws.accepter = aws.accepter
aws.requester = aws.requester
}
}
```

The `arn:aws:iam::XXXXXXXX:role/cross-account-vpc-peering-test` requester IAM Role should have the following Trust Policy:
The requester IAM Role should have the following Trust Policy:

<details><summary>Show Trust Policy</summary>

Expand Down Expand Up @@ -216,7 +217,7 @@ where `XXXXXXXX` is the requester AWS account ID.

<br/>

The `arn:aws:iam::YYYYYYYY:role/cross-account-vpc-peering-test` accepter IAM Role should have the following Trust Policy:
The accepter IAM Role should have the following Trust Policy:

<details><summary>Show Trust Policy</summary>

Expand Down Expand Up @@ -370,12 +371,6 @@ Available targets:
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_accepter_allow_remote_vpc_dns_resolution"></a> [accepter\_allow\_remote\_vpc\_dns\_resolution](#input\_accepter\_allow\_remote\_vpc\_dns\_resolution) | Allow accepter VPC to resolve public DNS hostnames to private IP addresses when queried from instances in the requester VPC | `bool` | `true` | no |
| <a name="input_accepter_aws_access_key"></a> [accepter\_aws\_access\_key](#input\_accepter\_aws\_access\_key) | Access key id to use in accepter account | `string` | `null` | no |
| <a name="input_accepter_aws_assume_role_arn"></a> [accepter\_aws\_assume\_role\_arn](#input\_accepter\_aws\_assume\_role\_arn) | Accepter AWS Assume Role ARN | `string` | n/a | yes |
| <a name="input_accepter_aws_profile"></a> [accepter\_aws\_profile](#input\_accepter\_aws\_profile) | Profile used to assume accepter\_aws\_assume\_role\_arn | `string` | `""` | no |
| <a name="input_accepter_aws_secret_key"></a> [accepter\_aws\_secret\_key](#input\_accepter\_aws\_secret\_key) | Secret access key to use in accepter account | `string` | `null` | no |
| <a name="input_accepter_aws_token"></a> [accepter\_aws\_token](#input\_accepter\_aws\_token) | Session token for validating temporary credentials | `string` | `null` | no |
| <a name="input_accepter_region"></a> [accepter\_region](#input\_accepter\_region) | Accepter AWS region | `string` | n/a | yes |
| <a name="input_accepter_subnet_tags"></a> [accepter\_subnet\_tags](#input\_accepter\_subnet\_tags) | Only add peer routes to accepter VPC route tables of subnets matching these tags | `map(string)` | `{}` | no |
| <a name="input_accepter_vpc_id"></a> [accepter\_vpc\_id](#input\_accepter\_vpc\_id) | Accepter VPC ID filter | `string` | `""` | no |
| <a name="input_accepter_vpc_tags"></a> [accepter\_vpc\_tags](#input\_accepter\_vpc\_tags) | Accepter VPC Tags filter | `map(string)` | `{}` | no |
Expand All @@ -395,12 +390,6 @@ Available targets:
| <a name="input_namespace"></a> [namespace](#input\_namespace) | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | `string` | `null` | no |
| <a name="input_regex_replace_chars"></a> [regex\_replace\_chars](#input\_regex\_replace\_chars) | Regex to replace chars with empty string in `namespace`, `environment`, `stage` and `name`.<br>If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no |
| <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 |
| <a name="input_requester_aws_access_key"></a> [requester\_aws\_access\_key](#input\_requester\_aws\_access\_key) | Access key id to use in requester account | `string` | `null` | no |
| <a name="input_requester_aws_assume_role_arn"></a> [requester\_aws\_assume\_role\_arn](#input\_requester\_aws\_assume\_role\_arn) | Requester AWS Assume Role ARN | `string` | n/a | yes |
| <a name="input_requester_aws_profile"></a> [requester\_aws\_profile](#input\_requester\_aws\_profile) | Profile used to assume requester\_aws\_assume\_role\_arn | `string` | `""` | no |
| <a name="input_requester_aws_secret_key"></a> [requester\_aws\_secret\_key](#input\_requester\_aws\_secret\_key) | Secret access key to use in requester account | `string` | `null` | no |
| <a name="input_requester_aws_token"></a> [requester\_aws\_token](#input\_requester\_aws\_token) | Session token for validating temporary credentials | `string` | `null` | no |
| <a name="input_requester_region"></a> [requester\_region](#input\_requester\_region) | Requester AWS region | `string` | n/a | yes |
| <a name="input_requester_subnet_tags"></a> [requester\_subnet\_tags](#input\_requester\_subnet\_tags) | Only add peer routes to requester VPC route tables of subnets matching these tags | `map(string)` | `{}` | no |
| <a name="input_requester_vpc_id"></a> [requester\_vpc\_id](#input\_requester\_vpc\_id) | Requester VPC ID filter | `string` | `""` | no |
| <a name="input_requester_vpc_tags"></a> [requester\_vpc\_tags](#input\_requester\_vpc\_tags) | Requester VPC Tags filter | `map(string)` | `{}` | no |
Expand All @@ -427,6 +416,7 @@ Like this project? Please give it a ★ on [our GitHub](https://github.com/cloud
Are you using this project or any of our other projects? Consider [leaving a testimonial][testimonial]. =)



## Related Projects

Check out these related projects.
Expand All @@ -436,8 +426,6 @@ Check out these related projects.
- [terraform-aws-kops-vpc-peering](https://github.com/cloudposse/terraform-aws-kops-vpc-peering) - Terraform module to create a peering connection between a backing services VPC and a VPC created by Kops




## References

For additional context, refer to some of these links.
Expand Down
13 changes: 7 additions & 6 deletions README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,20 @@ usage: |2-
stage = "dev"
name = "cluster"

requester_aws_assume_role_arn = "arn:aws:iam::XXXXXXXX:role/cross-account-vpc-peering-test"
requester_region = "us-west-2"
requester_vpc_id = "vpc-xxxxxxxx"
requester_allow_remote_vpc_dns_resolution = true

accepter_aws_assume_role_arn = "arn:aws:iam::YYYYYYYY:role/cross-account-vpc-peering-test"
accepter_region = "us-east-1"
accepter_vpc_id = "vpc-yyyyyyyy"
accepter_allow_remote_vpc_dns_resolution = true

providers = {
aws.accepter = aws.accepter
aws.requester = aws.requester
Comment on lines +104 to +105
Copy link
Member

Choose a reason for hiding this comment

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

Showing how to set these providers above would be helpful for copying and pasting the example.

}
}
```

The `arn:aws:iam::XXXXXXXX:role/cross-account-vpc-peering-test` requester IAM Role should have the following Trust Policy:
The requester IAM Role should have the following Trust Policy:

<details><summary>Show Trust Policy</summary>

Expand Down Expand Up @@ -173,7 +174,7 @@ usage: |2-

<br/>

The `arn:aws:iam::YYYYYYYY:role/cross-account-vpc-peering-test` accepter IAM Role should have the following Trust Policy:
The accepter IAM Role should have the following Trust Policy:

<details><summary>Show Trust Policy</summary>

Expand Down
16 changes: 1 addition & 15 deletions accepter.tf
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
# Accepter's credentials
provider "aws" {
heathsnow marked this conversation as resolved.
Show resolved Hide resolved
alias = "accepter"
region = var.accepter_region
profile = var.accepter_aws_profile
skip_metadata_api_check = var.skip_metadata_api_check

dynamic "assume_role" {
for_each = var.accepter_aws_assume_role_arn != "" ? ["true"] : []
content {
role_arn = var.accepter_aws_assume_role_arn
}
}

access_key = var.accepter_aws_access_key
secret_key = var.accepter_aws_secret_key
token = var.accepter_aws_token
alias = "accepter"
}

module "accepter" {
Expand Down
12 changes: 0 additions & 12 deletions docs/terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_accepter_allow_remote_vpc_dns_resolution"></a> [accepter\_allow\_remote\_vpc\_dns\_resolution](#input\_accepter\_allow\_remote\_vpc\_dns\_resolution) | Allow accepter VPC to resolve public DNS hostnames to private IP addresses when queried from instances in the requester VPC | `bool` | `true` | no |
| <a name="input_accepter_aws_access_key"></a> [accepter\_aws\_access\_key](#input\_accepter\_aws\_access\_key) | Access key id to use in accepter account | `string` | `null` | no |
| <a name="input_accepter_aws_assume_role_arn"></a> [accepter\_aws\_assume\_role\_arn](#input\_accepter\_aws\_assume\_role\_arn) | Accepter AWS Assume Role ARN | `string` | n/a | yes |
| <a name="input_accepter_aws_profile"></a> [accepter\_aws\_profile](#input\_accepter\_aws\_profile) | Profile used to assume accepter\_aws\_assume\_role\_arn | `string` | `""` | no |
| <a name="input_accepter_aws_secret_key"></a> [accepter\_aws\_secret\_key](#input\_accepter\_aws\_secret\_key) | Secret access key to use in accepter account | `string` | `null` | no |
| <a name="input_accepter_aws_token"></a> [accepter\_aws\_token](#input\_accepter\_aws\_token) | Session token for validating temporary credentials | `string` | `null` | no |
| <a name="input_accepter_region"></a> [accepter\_region](#input\_accepter\_region) | Accepter AWS region | `string` | n/a | yes |
| <a name="input_accepter_subnet_tags"></a> [accepter\_subnet\_tags](#input\_accepter\_subnet\_tags) | Only add peer routes to accepter VPC route tables of subnets matching these tags | `map(string)` | `{}` | no |
| <a name="input_accepter_vpc_id"></a> [accepter\_vpc\_id](#input\_accepter\_vpc\_id) | Accepter VPC ID filter | `string` | `""` | no |
| <a name="input_accepter_vpc_tags"></a> [accepter\_vpc\_tags](#input\_accepter\_vpc\_tags) | Accepter VPC Tags filter | `map(string)` | `{}` | no |
Expand All @@ -73,12 +67,6 @@
| <a name="input_namespace"></a> [namespace](#input\_namespace) | Namespace, which could be your organization name or abbreviation, e.g. 'eg' or 'cp' | `string` | `null` | no |
| <a name="input_regex_replace_chars"></a> [regex\_replace\_chars](#input\_regex\_replace\_chars) | Regex to replace chars with empty string in `namespace`, `environment`, `stage` and `name`.<br>If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no |
| <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 |
| <a name="input_requester_aws_access_key"></a> [requester\_aws\_access\_key](#input\_requester\_aws\_access\_key) | Access key id to use in requester account | `string` | `null` | no |
| <a name="input_requester_aws_assume_role_arn"></a> [requester\_aws\_assume\_role\_arn](#input\_requester\_aws\_assume\_role\_arn) | Requester AWS Assume Role ARN | `string` | n/a | yes |
| <a name="input_requester_aws_profile"></a> [requester\_aws\_profile](#input\_requester\_aws\_profile) | Profile used to assume requester\_aws\_assume\_role\_arn | `string` | `""` | no |
| <a name="input_requester_aws_secret_key"></a> [requester\_aws\_secret\_key](#input\_requester\_aws\_secret\_key) | Secret access key to use in requester account | `string` | `null` | no |
| <a name="input_requester_aws_token"></a> [requester\_aws\_token](#input\_requester\_aws\_token) | Session token for validating temporary credentials | `string` | `null` | no |
| <a name="input_requester_region"></a> [requester\_region](#input\_requester\_region) | Requester AWS region | `string` | n/a | yes |
| <a name="input_requester_subnet_tags"></a> [requester\_subnet\_tags](#input\_requester\_subnet\_tags) | Only add peer routes to requester VPC route tables of subnets matching these tags | `map(string)` | `{}` | no |
| <a name="input_requester_vpc_id"></a> [requester\_vpc\_id](#input\_requester\_vpc\_id) | Requester VPC ID filter | `string` | `""` | no |
| <a name="input_requester_vpc_tags"></a> [requester\_vpc\_tags](#input\_requester\_vpc\_tags) | Requester VPC Tags filter | `map(string)` | `{}` | no |
Expand Down
51 changes: 1 addition & 50 deletions requester.tf
Original file line number Diff line number Diff line change
@@ -1,37 +1,3 @@
variable "requester_aws_profile" {
description = "Profile used to assume requester_aws_assume_role_arn"
type = string
default = ""
}

variable "requester_aws_access_key" {
description = "Access key id to use in requester account"
type = string
default = null
}

variable "requester_aws_assume_role_arn" {
description = "Requester AWS Assume Role ARN"
type = string
}

variable "requester_aws_secret_key" {
description = "Secret access key to use in requester account"
type = string
default = null
}

variable "requester_aws_token" {
description = "Session token for validating temporary credentials"
type = string
default = null
}

variable "requester_region" {
type = string
description = "Requester AWS region"
}

variable "requester_subnet_tags" {
type = map(string)
description = "Only add peer routes to requester VPC route tables of subnets matching these tags"
Expand All @@ -58,22 +24,7 @@ variable "requester_allow_remote_vpc_dns_resolution" {

# Requestors's credentials
provider "aws" {
alias = "requester"
region = var.requester_region
profile = var.requester_aws_profile
skip_metadata_api_check = var.skip_metadata_api_check

dynamic "assume_role" {
for_each = var.requester_aws_assume_role_arn != "" ? ["true"] : []
content {
role_arn = var.requester_aws_assume_role_arn
}
}

access_key = var.requester_aws_access_key
secret_key = var.requester_aws_secret_key
token = var.requester_aws_token

alias = "requester"
}

module "requester" {
Expand Down
34 changes: 0 additions & 34 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,6 @@ variable "auto_accept" {
description = "Automatically accept the peering"
}

variable "accepter_aws_access_key" {
description = "Access key id to use in accepter account"
type = string
default = null
}

variable "accepter_aws_profile" {
description = "Profile used to assume accepter_aws_assume_role_arn"
type = string
default = ""
}

variable "accepter_aws_assume_role_arn" {
description = "Accepter AWS Assume Role ARN"
type = string
}

variable "accepter_aws_secret_key" {
description = "Secret access key to use in accepter account"
type = string
default = null
}

variable "accepter_aws_token" {
description = "Session token for validating temporary credentials"
type = string
default = null
}

variable "accepter_region" {
type = string
description = "Accepter AWS region"
}

variable "accepter_vpc_id" {
type = string
description = "Accepter VPC ID filter"
Expand Down