-
Notifications
You must be signed in to change notification settings - Fork 143
Route53 Record + vpc endpoint extensive #411
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
Open
bcarranza
wants to merge
36
commits into
main
Choose a base branch
from
route53-record
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
a15db2d
record route53
bcarranza 85dd220
fix output vars
bcarranza cfe494e
record route 53 aws transfer.
bcarranza 1912d6b
fix aws transfer attributes
bcarranza 1a6d036
record name
bcarranza 35d8425
fix module
bcarranza d48229f
region
bcarranza 2dac7e7
vpc id
bcarranza c70252c
dns_entry
bcarranza 515604d
output fixes
bcarranza 1f83d9f
arrays
bcarranza 133ab9f
fix arrays
bcarranza 2432d24
vpc endpoint id
bcarranza b24b4c6
vpc endpoint id
bcarranza 4674c8e
endpoint details
bcarranza fb736e5
endpoint_details
bcarranza a5915e7
other way to get vpc endpoint it.
bcarranza 6cfb974
fix
bcarranza 72addb6
test harcoding
bcarranza 65107a8
testing local-exec
bcarranza 6357618
depends on
bcarranza 53cb426
typo data
bcarranza 47d0664
null_resource.cluster.triggers.output
bcarranza 0da8c72
local exec provisioner
bcarranza 9bfdabd
typos in output
bcarranza 0c9a927
add content
bcarranza c6b491f
remove quotes
bcarranza fd0c374
trim function
bcarranza 1578e98
vpc id
bcarranza 07442a1
change name of txt
bcarranza e0c1e74
replace trim
bcarranza d54211e
typo trim
bcarranza 602ea17
typo replace
bcarranza d301f73
remove new lines
bcarranza 1bf5434
route 53 v2
bcarranza a7e7c7e
remove second test to vpc endpoint by state
bcarranza File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
terraform-modules/aws/route53/record-vpc-endpoint-sftp-transfer/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| ## Requirements | ||
|
|
||
| No requirements. | ||
|
|
||
| ## Providers | ||
|
|
||
| | Name | Version | | ||
| |------|---------| | ||
| | <a name="provider_aws"></a> [aws](#provider\_aws) | n/a | | ||
|
|
||
| ## Modules | ||
|
|
||
| | Name | Source | Version | | ||
| |------|--------|---------| | ||
| | <a name="module_record"></a> [record](#module\_record) | ../record/ | n/a | | ||
|
|
||
| ## Resources | ||
|
|
||
| | Name | Type | | ||
| |------|------| | ||
| | [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source | | ||
| | [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source | | ||
| | [aws_transfer_server.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/transfer_server) | data source | | ||
| | [aws_vpc_endpoint.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/vpc_endpoint) | data source | | ||
| | [aws_vpc_endpoint_service.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/vpc_endpoint_service) | data source | | ||
|
|
||
| ## Inputs | ||
|
|
||
| | Name | Description | Type | Default | Required | | ||
| |------|-------------|------|---------|:--------:| | ||
| | <a name="input_evaluate_target_health"></a> [evaluate\_target\_health](#input\_evaluate\_target\_health) | whether or not Route 53 should perform health checks on the target of an alias record before responding to DNS queries. | `bool` | `false` | no | | ||
| | <a name="input_record_name"></a> [record\_name](#input\_record\_name) | The name for the Route 53 record. | `string` | n/a | yes | | ||
| | <a name="input_route53_zone_id"></a> [route53\_zone\_id](#input\_route53\_zone\_id) | The ID of the Route 53 zone where the record will be created. | `string` | n/a | yes | | ||
| | <a name="input_transfer_server_id"></a> [transfer\_server\_id](#input\_transfer\_server\_id) | The ID of the AWS Transfer Server | `string` | `""` | no | | ||
| | <a name="input_type"></a> [type](#input\_type) | Also known as an Address record, is used to map a domain name to an IP address. | `string` | `"A"` | no | | ||
| | <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | The VPC ID Where VPC enpoint is configured | `string` | `""` | no | | ||
|
|
||
| ## Outputs | ||
|
|
||
| | Name | Description | | ||
| |------|-------------| | ||
| | <a name="output_fqdn"></a> [fqdn](#output\_fqdn) | FQDN built using the zone domain and name. | | ||
| | <a name="output_name"></a> [name](#output\_name) | The name for the Route 53 record. | | ||
| | <a name="output_vpc_endpoint_dns_entry"></a> [vpc\_endpoint\_dns\_entry](#output\_vpc\_endpoint\_dns\_entry) | Retrieve the DNS name associated with an AWS VPC Endpoint. | | ||
| | <a name="output_vpc_endpoint_dns_name"></a> [vpc\_endpoint\_dns\_name](#output\_vpc\_endpoint\_dns\_name) | Retrieves the primary DNS name associated with the VPC Endpoint | | ||
| | <a name="output_vpc_endpoint_id"></a> [vpc\_endpoint\_id](#output\_vpc\_endpoint\_id) | ID of an AWS VPC Endpoint | |
42 changes: 42 additions & 0 deletions
42
terraform-modules/aws/route53/record-vpc-endpoint-sftp-transfer/main.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
|
|
||
| data "aws_caller_identity" "current" {} | ||
| data "aws_region" "current" {} | ||
|
|
||
|
|
||
| resource "null_resource" "output-vpc-endpoint-id" { | ||
| provisioner "local-exec" { | ||
| command = "aws transfer describe-server --server-id ${var.transfer_server_id} --query 'Server.EndpointDetails.VpcEndpointId' > ${data.template_file.log_name.rendered}" | ||
| } | ||
| } | ||
|
|
||
| data "template_file" "log_name" { | ||
| template = "${path.module}/vpc-endpoint-id.txt" | ||
| } | ||
|
|
||
| data "local_file" "get-vpc-endpoint-id-value" { | ||
| filename = "${data.template_file.log_name.rendered}" | ||
| depends_on = [null_resource.output-vpc-endpoint-id] | ||
| } | ||
|
|
||
| # Get the VPC Endpoint ID for the Transfer Service | ||
| data "aws_vpc_endpoint" "this" { | ||
| # Remove quotes and new lines | ||
| id = trim(replace(replace(data.local_file.get-vpc-endpoint-id-value.content, "\"", ""),"/\"|\r\n|\r|\n/",""), "") | ||
| vpc_id = var.vpc_id | ||
|
|
||
| depends_on = [ | ||
| data.local_file.get-vpc-endpoint-id-value | ||
| ] | ||
| } | ||
|
|
||
| module "record" { | ||
| source = "../record/" | ||
| route53_zone_id = var.route53_zone_id | ||
| record_name = var.record_name | ||
| vpc_endpoint_dns_name = data.aws_vpc_endpoint.this.dns_entry[0].dns_name | ||
| vpc_endpoint_zone_id = data.aws_vpc_endpoint.this.dns_entry[0].hosted_zone_id | ||
|
|
||
| depends_on = [ | ||
| data.aws_vpc_endpoint.this | ||
| ] | ||
| } | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am reusing the first terraform called only record ! |
||
24 changes: 24 additions & 0 deletions
24
terraform-modules/aws/route53/record-vpc-endpoint-sftp-transfer/outputs.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| output "name" { | ||
| value = module.record.name | ||
| description = "The name for the Route 53 record." | ||
| } | ||
|
|
||
| output "fqdn" { | ||
| value = module.record.fqdn | ||
| description = "FQDN built using the zone domain and name." | ||
| } | ||
|
|
||
| output "vpc_endpoint_id" { | ||
| value = data.aws_vpc_endpoint.this.id | ||
| description = "ID of an AWS VPC Endpoint" | ||
| } | ||
|
|
||
| output "vpc_endpoint_dns_name" { | ||
| value = data.aws_vpc_endpoint.this.dns_entry[0].dns_name | ||
| description = "Retrieve the DNS name associated with an AWS VPC Endpoint." | ||
| } | ||
|
|
||
| output "vpc_endpoint_hosted_zone_id" { | ||
| value = data.aws_vpc_endpoint.this.dns_entry[0].hosted_zone_id | ||
| description = "Retrieves the Zona ID name associated with the VPC Endpoint" | ||
| } |
34 changes: 34 additions & 0 deletions
34
terraform-modules/aws/route53/record-vpc-endpoint-sftp-transfer/variables.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| variable "route53_zone_id" { | ||
| description = "The ID of the Route 53 zone where the record will be created." | ||
| type = string | ||
| } | ||
|
|
||
| variable "record_name" { | ||
| description = "The name for the Route 53 record." | ||
| type = string | ||
| } | ||
|
|
||
| variable "type" { | ||
| type = string | ||
| default = "A" | ||
| description = "Also known as an Address record, is used to map a domain name to an IP address." | ||
| } | ||
|
|
||
| variable "evaluate_target_health" { | ||
| type = bool | ||
| default = false | ||
| description = "whether or not Route 53 should perform health checks on the target of an alias record before responding to DNS queries." | ||
| } | ||
|
|
||
| variable "transfer_server_id" { | ||
| type = string | ||
| default = "" | ||
| description = "The ID of the AWS Transfer Server" | ||
| } | ||
|
|
||
| variable vpc_id { | ||
| type = string | ||
| default = "" | ||
| description = "The VPC ID Where VPC enpoint is configured" | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| ## Requirements | ||
|
|
||
| No requirements. | ||
|
|
||
| ## Providers | ||
|
|
||
| | Name | Version | | ||
| |------|---------| | ||
| | <a name="provider_aws"></a> [aws](#provider\_aws) | n/a | | ||
|
|
||
| ## Modules | ||
|
|
||
| No modules. | ||
|
|
||
| ## Resources | ||
|
|
||
| | Name | Type | | ||
| |------|------| | ||
| | [aws_route53_record.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_record) | resource | | ||
|
|
||
| ## Inputs | ||
|
|
||
| | Name | Description | Type | Default | Required | | ||
| |------|-------------|------|---------|:--------:| | ||
| | <a name="input_evaluate_target_health"></a> [evaluate\_target\_health](#input\_evaluate\_target\_health) | whether or not Route 53 should perform health checks on the target of an alias record before responding to DNS queries. | `bool` | `false` | no | | ||
| | <a name="input_record_name"></a> [record\_name](#input\_record\_name) | The name for the Route 53 record. | `string` | n/a | yes | | ||
| | <a name="input_route53_zone_id"></a> [route53\_zone\_id](#input\_route53\_zone\_id) | The ID of the Route 53 zone where the record will be created. | `string` | n/a | yes | | ||
| | <a name="input_type"></a> [type](#input\_type) | Also known as an Address record, is used to map a domain name to an IP address. | `string` | `"A"` | no | | ||
| | <a name="input_vpc_endpoint_dns_name"></a> [vpc\_endpoint\_dns\_name](#input\_vpc\_endpoint\_dns\_name) | The DNS name of the VPC Endpoint. | `string` | n/a | yes | | ||
| | <a name="input_vpc_endpoint_zone_id"></a> [vpc\_endpoint\_zone\_id](#input\_vpc\_endpoint\_zone\_id) | The ID of the Hosted Zone for the VPC Endpoint. | `string` | n/a | yes | | ||
|
|
||
| ## Outputs | ||
|
|
||
| | Name | Description | | ||
| |------|-------------| | ||
| | <a name="output_fqdn"></a> [fqdn](#output\_fqdn) | FQDN built using the zone domain and name. | | ||
| | <a name="output_name"></a> [name](#output\_name) | The name for the Route 53 record. | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| resource "aws_route53_record" "this" { | ||
| zone_id = var.route53_zone_id | ||
| name = var.record_name | ||
| type = var.type | ||
| alias { | ||
| name = var.vpc_endpoint_dns_name | ||
| zone_id = var.vpc_endpoint_zone_id | ||
| evaluate_target_health = false | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| output "name" { | ||
| value = aws_route53_record.this.name | ||
| description = "The name for the Route 53 record." | ||
| } | ||
|
|
||
| output "fqdn" { | ||
| value = aws_route53_record.this.fqdn | ||
| description = "FQDN built using the zone domain and name." | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| variable "route53_zone_id" { | ||
| description = "The ID of the Route 53 zone where the record will be created." | ||
| type = string | ||
| } | ||
|
|
||
| variable "record_name" { | ||
| description = "The name for the Route 53 record." | ||
| type = string | ||
| } | ||
|
|
||
| variable "type" { | ||
| type = string | ||
| default = "A" | ||
| description = "Also known as an Address record, is used to map a domain name to an IP address." | ||
| } | ||
|
|
||
|
|
||
| variable "vpc_endpoint_dns_name" { | ||
| description = "The DNS name of the VPC Endpoint." | ||
| type = string | ||
| } | ||
|
|
||
| variable "vpc_endpoint_zone_id" { | ||
| description = "The ID of the Hosted Zone for the VPC Endpoint." | ||
| type = string | ||
| } | ||
|
|
||
| variable "evaluate_target_health" { | ||
| type = bool | ||
| default = false | ||
| description = "whether or not Route 53 should perform health checks on the target of an alias record before responding to DNS queries." | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems extremely to use a provisioner to get vpc id enpdoint, but it is working well.

aws transfer module in aws and cloud posse doesn't have an output to vpc endpoint id.
Even terraform state has the value, but is a primitive string, so its forbidden to get.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cloud posse: https://github.com/cloudposse/terraform-aws-transfer-sftp
aws terraform provider: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/transfer_server