Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
a15db2d
record route53
bcarranza Mar 1, 2023
85dd220
fix output vars
bcarranza Mar 2, 2023
cfe494e
record route 53 aws transfer.
bcarranza Mar 2, 2023
1912d6b
fix aws transfer attributes
bcarranza Mar 2, 2023
1a6d036
record name
bcarranza Mar 2, 2023
35d8425
fix module
bcarranza Mar 2, 2023
d48229f
region
bcarranza Mar 2, 2023
2dac7e7
vpc id
bcarranza Mar 2, 2023
c70252c
dns_entry
bcarranza Mar 2, 2023
515604d
output fixes
bcarranza Mar 2, 2023
1f83d9f
arrays
bcarranza Mar 2, 2023
133ab9f
fix arrays
bcarranza Mar 2, 2023
2432d24
vpc endpoint id
bcarranza Mar 3, 2023
b24b4c6
vpc endpoint id
bcarranza Mar 3, 2023
4674c8e
endpoint details
bcarranza Mar 3, 2023
fb736e5
endpoint_details
bcarranza Mar 3, 2023
a5915e7
other way to get vpc endpoint it.
bcarranza Mar 3, 2023
6cfb974
fix
bcarranza Mar 3, 2023
72addb6
test harcoding
bcarranza Mar 3, 2023
65107a8
testing local-exec
bcarranza Mar 3, 2023
6357618
depends on
bcarranza Mar 3, 2023
53cb426
typo data
bcarranza Mar 3, 2023
47d0664
null_resource.cluster.triggers.output
bcarranza Mar 3, 2023
0da8c72
local exec provisioner
bcarranza Mar 3, 2023
9bfdabd
typos in output
bcarranza Mar 3, 2023
0c9a927
add content
bcarranza Mar 3, 2023
c6b491f
remove quotes
bcarranza Mar 3, 2023
fd0c374
trim function
bcarranza Mar 3, 2023
1578e98
vpc id
bcarranza Mar 3, 2023
07442a1
change name of txt
bcarranza Mar 3, 2023
e0c1e74
replace trim
bcarranza Mar 3, 2023
d54211e
typo trim
bcarranza Mar 3, 2023
602ea17
typo replace
bcarranza Mar 3, 2023
d301f73
remove new lines
bcarranza Mar 3, 2023
1bf5434
route 53 v2
bcarranza Mar 6, 2023
a7e7c7e
remove second test to vpc endpoint by state
bcarranza Mar 6, 2023
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
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 |
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}"
Copy link
Collaborator Author

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.
Screenshot 2023-03-03 at 13 13 06

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

}
}

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
]
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am reusing the first terraform called only record !

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"
}
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"
}

37 changes: 37 additions & 0 deletions terraform-modules/aws/route53/record/README.md
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. |
10 changes: 10 additions & 0 deletions terraform-modules/aws/route53/record/main.tf
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
}
}
9 changes: 9 additions & 0 deletions terraform-modules/aws/route53/record/outputs.tf
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."
}
32 changes: 32 additions & 0 deletions terraform-modules/aws/route53/record/variables.tf
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."
}