Skip to content

Commit

Permalink
Export dns_hostnames in outputs
Browse files Browse the repository at this point in the history
+ Use pytest-infrahouse fixtures
  • Loading branch information
akuzminsky committed Dec 12, 2024
1 parent fc9a8c1 commit 0b91194
Show file tree
Hide file tree
Showing 34 changed files with 85 additions and 373 deletions.
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ module "httpd" {

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.65.0 |
| <a name="provider_cloudinit"></a> [cloudinit](#provider\_cloudinit) | 2.3.4 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | ~> 5.56 |
| <a name="provider_cloudinit"></a> [cloudinit](#provider\_cloudinit) | ~> 2.3 |

## Modules

Expand Down Expand Up @@ -132,6 +132,7 @@ module "httpd" {
| [aws_iam_policy_document.instance_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_key_pair.ssh_key_pair](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/key_pair) | data source |
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
| [aws_route53_zone.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/route53_zone) | data source |
| [aws_subnet.selected](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/subnet) | data source |
| [cloudinit_config.ecs](https://registry.terraform.io/providers/hashicorp/cloudinit/latest/docs/data-sources/config) | data source |

Expand All @@ -151,7 +152,7 @@ module "httpd" {
| <a name="input_autoscaling_target"></a> [autoscaling\_target](#input\_autoscaling\_target) | Target value for autoscaling\_metric. | `number` | `null` | no |
| <a name="input_autoscaling_target_cpu_usage"></a> [autoscaling\_target\_cpu\_usage](#input\_autoscaling\_target\_cpu\_usage) | If autoscaling\_metric is ECSServiceAverageCPUUtilization, how much CPU an ECS service aims to use. | `number` | `80` | no |
| <a name="input_cloudwatch_agent_config_path"></a> [cloudwatch\_agent\_config\_path](#input\_cloudwatch\_agent\_config\_path) | Path to cloudwatch agent config on host fs | `string` | `""` | no |
| <a name="input_cloudwatch_agent_container_resources"></a> [cloudwatch\_agent\_container\_resources](#input\_cloudwatch\_agent\_container\_resources) | Resourcces for cloudwatch agent container | <pre>object({<br> cpu = number<br> memory = number<br> })</pre> | <pre>{<br> "cpu": 128,<br> "memory": 256<br>}</pre> | no |
| <a name="input_cloudwatch_agent_container_resources"></a> [cloudwatch\_agent\_container\_resources](#input\_cloudwatch\_agent\_container\_resources) | Resourcces for cloudwatch agent container | <pre>object({<br/> cpu = number<br/> memory = number<br/> })</pre> | <pre>{<br/> "cpu": 128,<br/> "memory": 256<br/>}</pre> | no |
| <a name="input_cloudwatch_agent_image"></a> [cloudwatch\_agent\_image](#input\_cloudwatch\_agent\_image) | Cloudwatch agent image | `string` | `"amazon/cloudwatch-agent:1.300037.1b602"` | no |
| <a name="input_cloudwatch_log_group"></a> [cloudwatch\_log\_group](#input\_cloudwatch\_log\_group) | CloudWatch log group to create and use. Default: /ecs/{name}-{environment} | `string` | `null` | no |
| <a name="input_cloudwatch_log_group_retention"></a> [cloudwatch\_log\_group\_retention](#input\_cloudwatch\_log\_group\_retention) | Number of days you want to retain log events in the log group. | `number` | `90` | no |
Expand All @@ -167,7 +168,7 @@ module "httpd" {
| <a name="input_enable_cloudwatch_logs"></a> [enable\_cloudwatch\_logs](#input\_enable\_cloudwatch\_logs) | Enable Cloudwatch logs. If enabled, log driver will be awslogs. | `bool` | `false` | no |
| <a name="input_enable_container_insights"></a> [enable\_container\_insights](#input\_enable\_container\_insights) | Enable container insights feature on ECS cluster. | `bool` | `false` | no |
| <a name="input_environment"></a> [environment](#input\_environment) | Name of environment. | `string` | `"development"` | no |
| <a name="input_extra_files"></a> [extra\_files](#input\_extra\_files) | Additional files to create on a host EC2 instance. | <pre>list(object({<br> content = string<br> path = string<br> permissions = string<br> }))</pre> | `[]` | no |
| <a name="input_extra_files"></a> [extra\_files](#input\_extra\_files) | Additional files to create on a host EC2 instance. | <pre>list(object({<br/> content = string<br/> path = string<br/> permissions = string<br/> }))</pre> | `[]` | no |
| <a name="input_healthcheck_interval"></a> [healthcheck\_interval](#input\_healthcheck\_interval) | Number of seconds between checks | `number` | `10` | no |
| <a name="input_healthcheck_path"></a> [healthcheck\_path](#input\_healthcheck\_path) | Path on the webserver that the elb will check to determine whether the instance is healthy or not. | `string` | `"/index.html"` | no |
| <a name="input_healthcheck_response_code_matcher"></a> [healthcheck\_response\_code\_matcher](#input\_healthcheck\_response\_code\_matcher) | Range of http return codes that can match | `string` | `"200-299"` | no |
Expand All @@ -185,10 +186,10 @@ module "httpd" {
| <a name="input_ssh_cidr_block"></a> [ssh\_cidr\_block](#input\_ssh\_cidr\_block) | CIDR range that is allowed to SSH into the backend instances | `string` | `null` | no |
| <a name="input_ssh_key_name"></a> [ssh\_key\_name](#input\_ssh\_key\_name) | ssh key name installed in ECS host instances. | `string` | n/a | yes |
| <a name="input_task_desired_count"></a> [task\_desired\_count](#input\_task\_desired\_count) | Number of containers the ECS service will maintain. | `number` | `1` | no |
| <a name="input_task_efs_volumes"></a> [task\_efs\_volumes](#input\_task\_efs\_volumes) | Map name->{file\_system\_id, container\_path} of EFS volumes defined in task and available for containers to mount. | <pre>map(<br> object(<br> {<br> file_system_id : string<br> container_path : string<br> }<br> )<br> )</pre> | `{}` | no |
| <a name="input_task_environment_variables"></a> [task\_environment\_variables](#input\_task\_environment\_variables) | Environment variables passed down to a task. | <pre>list(<br> object(<br> {<br> name : string<br> value : string<br> }<br> )<br> )</pre> | `[]` | no |
| <a name="input_task_efs_volumes"></a> [task\_efs\_volumes](#input\_task\_efs\_volumes) | Map name->{file\_system\_id, container\_path} of EFS volumes defined in task and available for containers to mount. | <pre>map(<br/> object(<br/> {<br/> file_system_id : string<br/> container_path : string<br/> }<br/> )<br/> )</pre> | `{}` | no |
| <a name="input_task_environment_variables"></a> [task\_environment\_variables](#input\_task\_environment\_variables) | Environment variables passed down to a task. | <pre>list(<br/> object(<br/> {<br/> name : string<br/> value : string<br/> }<br/> )<br/> )</pre> | `[]` | no |
| <a name="input_task_ipc_mode"></a> [task\_ipc\_mode](#input\_task\_ipc\_mode) | The IPC resource namespace to use for the containers in the task. See https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_TaskDefinition.html | `string` | `null` | no |
| <a name="input_task_local_volumes"></a> [task\_local\_volumes](#input\_task\_local\_volumes) | Map name->{host\_path, container\_path} of local volumes defined in task and available for containers to mount. | <pre>map(<br> object(<br> {<br> host_path : string<br> container_path : string<br> }<br> )<br> )</pre> | `{}` | no |
| <a name="input_task_local_volumes"></a> [task\_local\_volumes](#input\_task\_local\_volumes) | Map name->{host\_path, container\_path} of local volumes defined in task and available for containers to mount. | <pre>map(<br/> object(<br/> {<br/> host_path : string<br/> container_path : string<br/> }<br/> )<br/> )</pre> | `{}` | no |
| <a name="input_task_max_count"></a> [task\_max\_count](#input\_task\_max\_count) | Highest number of tasks to run | `number` | `10` | no |
| <a name="input_task_min_count"></a> [task\_min\_count](#input\_task\_min\_count) | Lowest number of tasks to run | `number` | `1` | no |
| <a name="input_task_role_arn"></a> [task\_role\_arn](#input\_task\_role\_arn) | Task Role ARN. The role will be assumed by a container. | `string` | `null` | no |
Expand All @@ -201,5 +202,6 @@ module "httpd" {
|------|-------------|
| <a name="output_asg_arn"></a> [asg\_arn](#output\_asg\_arn) | Autoscaling group ARN created for the ECS service. |
| <a name="output_asg_name"></a> [asg\_name](#output\_asg\_name) | Autoscaling group name created for the ECS service. |
| <a name="output_dns_hostnames"></a> [dns\_hostnames](#output\_dns\_hostnames) | DNS hostnames where the ECS service is available. |
| <a name="output_load_balancer_dns_name"></a> [load\_balancer\_dns\_name](#output\_load\_balancer\_dns\_name) | Load balancer DNS name. |
| <a name="output_service_arn"></a> [service\_arn](#output\_service\_arn) | ECS service ARN. |
4 changes: 4 additions & 0 deletions datasources.tf
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,7 @@ data "aws_iam_policy_document" "ecs_cloudwatch_logs_policy" {
}

}

data "aws_route53_zone" "this" {
zone_id = var.zone_id
}
5 changes: 5 additions & 0 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,8 @@ output "load_balancer_dns_name" {
description = "Load balancer DNS name."
value = local.load_balancer_dns_name
}

output "dns_hostnames" {
description = "DNS hostnames where the ECS service is available."
value = [for h in var.dns_names : trimprefix(join(".", [h, data.aws_route53_zone.this.name]), ".")]
}
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ botocore ~= 1.31
bump2version ~= 1.0
infrahouse-toolkit ~= 2.0
myst-parser ~= 2.0
pytest ~= 7.3
pytest ~= 8.3
pytest-infrahouse ~= 0.3
pytest-timeout ~= 2.1
pytest-rerunfailures ~= 12.0
requests ~= 2.31
4 changes: 4 additions & 0 deletions test_data/httpd/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ output "zone_id" {
output "jumphost_hostname" {
value = random_pet.hostname.id
}

output "dns_hostnames" {
value = module.httpd.dns_hostnames
}
7 changes: 5 additions & 2 deletions test_data/httpd/providers.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
provider "aws" {
region = var.region
assume_role {
role_arn = var.role_arn
dynamic "assume_role" {
for_each = var.role_arn != null ? [1] : []
content {
role_arn = var.role_arn
}
}
default_tags {
tags = {
Expand Down
8 changes: 6 additions & 2 deletions test_data/httpd/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ variable "environment" {
default = "development"
}
variable "region" {}
variable "role_arn" {}
variable "role_arn" {
default = null
}
variable "service_name" {
default = "test-terraform-aws-ecs"
}
variable "task_role_arn" {}
variable "task_role_arn" {
default = null
}
variable "test_zone" {}
variable "ubuntu_codename" {
default = "jammy"
Expand Down
7 changes: 5 additions & 2 deletions test_data/httpd_autoscaling/providers.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
provider "aws" {
region = var.region
assume_role {
role_arn = var.role_arn
dynamic "assume_role" {
for_each = var.role_arn != null ? [1] : []
content {
role_arn = var.role_arn
}
}
default_tags {
tags = {
Expand Down
9 changes: 7 additions & 2 deletions test_data/httpd_autoscaling/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@ variable "environment" {
default = "development"
}
variable "region" {}
variable "role_arn" {}
variable "role_arn" {
default = null
}

variable "service_name" {
default = "test-terraform-aws-ecs"
}
variable "task_role_arn" {}
variable "task_role_arn" {
default = null
}
variable "test_zone" {}
variable "ubuntu_codename" {
default = "jammy"
Expand Down
7 changes: 5 additions & 2 deletions test_data/httpd_efs/providers.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
provider "aws" {
region = var.region
assume_role {
role_arn = var.role_arn
dynamic "assume_role" {
for_each = var.role_arn != null ? [1] : []
content {
role_arn = var.role_arn
}
}
default_tags {
tags = {
Expand Down
9 changes: 7 additions & 2 deletions test_data/httpd_efs/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@ variable "environment" {
default = "development"
}
variable "region" {}
variable "role_arn" {}
variable "role_arn" {
default = null
}

variable "service_name" {
default = "test-terraform-aws-ecs"
}
variable "task_role_arn" {}
variable "task_role_arn" {
default = null
}
variable "test_zone" {}
variable "ubuntu_codename" {
default = "jammy"
Expand Down
7 changes: 5 additions & 2 deletions test_data/httpd_tcp/providers.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
provider "aws" {
region = var.region
assume_role {
role_arn = var.role_arn
dynamic "assume_role" {
for_each = var.role_arn != null ? [1] : []
content {
role_arn = var.role_arn
}
}
default_tags {
tags = {
Expand Down
8 changes: 6 additions & 2 deletions test_data/httpd_tcp/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ variable "environment" {
default = "development"
}
variable "region" {}
variable "role_arn" {}
variable "role_arn" {
default = null
}
variable "service_name" {
default = "test-terraform-aws-ecs"
}
variable "task_role_arn" {}
variable "task_role_arn" {
default = null
}
variable "test_zone" {}
variable "ubuntu_codename" {
default = "jammy"
Expand Down
8 changes: 0 additions & 8 deletions test_data/jumphost/datasources.tf

This file was deleted.

8 changes: 0 additions & 8 deletions test_data/jumphost/keypair.tf

This file was deleted.

32 changes: 0 additions & 32 deletions test_data/jumphost/main.tf

This file was deleted.

Empty file removed test_data/jumphost/outputs.tf
Empty file.
12 changes: 0 additions & 12 deletions test_data/jumphost/providers.tf

This file was deleted.

9 changes: 0 additions & 9 deletions test_data/jumphost/ssh_keys/ssh_host_ecdsa_key

This file was deleted.

1 change: 0 additions & 1 deletion test_data/jumphost/ssh_keys/ssh_host_ecdsa_key.pub

This file was deleted.

7 changes: 0 additions & 7 deletions test_data/jumphost/ssh_keys/ssh_host_ed25519_key

This file was deleted.

1 change: 0 additions & 1 deletion test_data/jumphost/ssh_keys/ssh_host_ed25519_key.pub

This file was deleted.

38 changes: 0 additions & 38 deletions test_data/jumphost/ssh_keys/ssh_host_rsa_key

This file was deleted.

1 change: 0 additions & 1 deletion test_data/jumphost/ssh_keys/ssh_host_rsa_key.pub

This file was deleted.

9 changes: 0 additions & 9 deletions test_data/jumphost/terraform.tf

This file was deleted.

12 changes: 0 additions & 12 deletions test_data/jumphost/variables.tf

This file was deleted.

5 changes: 0 additions & 5 deletions test_data/service-network/datasources.tf

This file was deleted.

Loading

0 comments on commit 0b91194

Please sign in to comment.