Skip to content

Commit

Permalink
Fix Terraform upgrade issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
agassner committed Feb 3, 2020
1 parent c3d0bce commit 17a6b2b
Show file tree
Hide file tree
Showing 13 changed files with 503 additions and 291 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.cache
.terraform
.cache
__pycache__
plan.out
15 changes: 5 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
sudo: required

services:
- docker

- docker
install: true
script: "./test/run.sh"

script: "./test/run"
branches:
only:
- master

- master
notifications:
slack:
secure: wDmnyotXpvrCsE3oUecQbRgplGqaweJhlEH6C6lYAFQ+uTtjT7n2K3a5eJY54TVKXKC1eZn7vuYKcopfZbv/NvjYy7ALHTDTa8c+w0sqTiSKlUHmcSjHSuCb2yOMAM80guLy3v7nuibCUd3utHbkw0bF1Wl6fhONRTHwBkSrGnHAaWyfbzuBIEIAUVBpCtPnhmWLo/OID9z+vqXOnVnVSiP0tO7lT9Dd/ddv+ZIerxjXZbCEOd3kUnxQrPz8bYKgUgUTj9qrjpw92lHrgLjWrMqJ/FC4n2+aQ6mXEgZqBSwTvW5xvmQP88bUI0ynShrW0NxUVHzgxlHXzucoLBG2N8Grk9VdVueCzBOXoDfYUu+l4OW8JapHFaAYFq0IxTeOE3X/ilxHUZkBD9x5tNRDzAdbTTvjLC8aMrKI2nDBTTQFupxSI5uUqS5FxwYKnbxuuU5BgkZUeeqIuyaMi0TNTaUD5ThOUz79RwCIjqaoMlOF+vj10LnNeZDQbUX1X/9Q8+5v76y9KU9HOYO16maa5J5cIN9bfOYBvTKu9FG63rgtfH6lE0vPZoFrOpKxfLUbzbCxLlrbb3VXKuE03QRfEVywIcYva4O12BCSMnx2B57Bn0GOygFTmBFrh4j0jUyhUXhFpzc2wIsRjrocRwHq18rKAOMhy0cLeEdeWyNhjxc=
on_success: change
secure: cUXbyPV2c+iOvvMeu2OsQJ/gnxlJuBEIhrd5dwA8bXzVgq1HAVw3KW9D9AawQR6dfqGB0DUxYC4Ir6WhhY2gJ4pO1yiLwXDBlkQZYfkDV6pjVD7iKfWJU6JUMZyUaQo3RLEk0WGUJgO29eFWBcHH3C8FI1yZKqYEQODj+QlgwG6Y4jn3MeA52eYmD0UflgY8vJROple/Y4kENWJIg0QB0dV4HOc5NFjW9sZFJv7/eb4q7H+xPL10XVcuXQI3TQ3Z8fyBg1Ur59DD+T3CIaDjytDPkcKoZw0H1JzmelU45paAdRPonIpm+DJ3yrVlC00i6JuMPest56Sx6Lx/QwS0TLEjwGKuwL7P0WD8EP+pAs9KBBrPphohaCJroL1SUGP0Tjjk78G3LzW2Y4HSDrkcdLbRb1Jmz/D2BvTayZsds/TOIq5TFKE1dI838iFgLpjwm6DT2hyQxow8hQXavxP2f9fLtLBcjn7PHFeH5LwwsJIe6qrYa7/VAlxxr9OJQHBlad92J5ROkdJjWVRAfLQKux4V0ZvsjGcMs11Q95UEnbpW/qQqS6lm4r5v6JixkAmqx5LZbHppRK1K7jYc2hO05Zy4kQtvWJmrtHAG/PPlOh7ai8p0zzNXvY+mFbaqh8jaBKFUcoVniDWfReNFei0hV9ikcfaJChNa7guueztUScM=
on_success: change
email: false

15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
AWS ALB terraform module
======================================

[![Build Status](https://travis-ci.org/mergermarket/tf_alb.svg?branch=master)](https://travis-ci.org/mergermarket/tf_alb)
[![Build Status](https://travis-ci.org/mergermarket/terraform-acuris-alb.svg?branch=master)](https://travis-ci.org/mergermarket/terraform-acuris-alb)

This module creates AWS Application Load Balancer as per provided parameters.

Expand All @@ -10,7 +10,9 @@ As some more resources - security-group and listener are required when creating
This module will output AWS ALB's `dns_name` and `listener_arn` which can be used to integrate with it.

Module Input Variables

----------------------

- `name` - (string) - **REQUIRED** - The name of the ALB. This name must be unique within your AWS account, can have a maximum of 32 characters, must contain only alphanumeric characters or hyphens, and must not begin or end with a hyphen
- `vpc_id` - (string) - **REQUIRED** - The id of the VPC that the ALB should be placed in
- `subnet_ids` - (list) - **REQUIRED** - A list of subnet IDs to attach to the ALB
Expand All @@ -21,10 +23,13 @@ Module Input Variables
- `tags` - (map) - OPTIONAL - Map of tags to be applied to the resources (just to ALB as ALB Listeners cannot be tagged); default: `{}` (empty - no tags)

Usage
-----

----------------------

```hcl
module "alb_test" {
source = "github.com/mergermarket/tf_alb"
source = "mergermarket/alb/acuris"
version = "2.0.0"
# required
name = "foobar-alb"
Expand All @@ -36,6 +41,8 @@ module "alb_test" {
```

Outputs
-------

----------------------

- `alb_dns_name` - The DNS name of the load balancer
- `alb_listener_arn` - The ARN of the load balancer
25 changes: 8 additions & 17 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
module "aws_acm_certificate_arn" {
source = "./modules/aws_acm_certificate_arn"
run_data = var.run_data
domain_name = var.certificate_domain_name
data "aws_acm_certificate" "cert" {
count = var.run_data ? 1 : 0
domain = var.certificate_domain_name
statuses = ["ISSUED"]
}

resource "aws_alb" "alb" {
name = replace(replace(var.name, "/(.{0,32}).*/", "$1"), "/^-+|-+$/", "")
internal = var.internal
# TF-UPGRADE-TODO: In Terraform v0.10 and earlier, it was sometimes necessary to
# force an interpolation expression to be interpreted as a list by wrapping it
# in an extra set of list brackets. That form was supported for compatibility in
# v0.11, but is no longer supported in Terraform v0.12.
#
# If the expression in the following list itself returns a list, remove the
# brackets to avoid interpretation as a list of lists. If the expression
# returns a single list item then leave it as-is and remove this TODO comment.
security_groups = [concat([aws_security_group.default.id], var.extra_security_groups)]
name = replace(replace(var.name, "/(.{0,32}).*/", "$1"), "/^-+|-+$/", "")
internal = var.internal
security_groups = concat([aws_security_group.default.id], var.extra_security_groups)
subnets = var.subnet_ids
tags = var.tags
idle_timeout = var.idle_timeout
Expand All @@ -30,11 +22,10 @@ resource "aws_alb_listener" "https" {
load_balancer_arn = aws_alb.alb.arn
port = "443"
protocol = "HTTPS"
certificate_arn = module.aws_acm_certificate_arn.arn
certificate_arn = element(concat(data.aws_acm_certificate.cert.*.arn, [""]), 0)

default_action {
target_group_arn = var.default_target_group_arn
type = "forward"
}
}

5 changes: 0 additions & 5 deletions modules/aws_acm_certificate_arn/main.tf

This file was deleted.

3 changes: 0 additions & 3 deletions modules/aws_acm_certificate_arn/outputs.tf

This file was deleted.

9 changes: 0 additions & 9 deletions modules/aws_acm_certificate_arn/variables.tf

This file was deleted.

6 changes: 3 additions & 3 deletions test/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM python:3-alpine3.8
FROM python:3-alpine
COPY requirements.txt .

ENV TERRAFORM_VERSION=0.11.11
ENV TERRAFORM_VERSION=0.12.19
ENV TERRAFORM_ZIP=terraform_${TERRAFORM_VERSION}_linux_amd64.zip
ENV TERRAFORM_SUM=94504f4a67bad612b5c8e3a4b7ce6ca2772b3c1559630dfd71e9c519e3d6149c
ENV TERRAFORM_SUM=a549486112f5350075fb540cfd873deb970a9baf8a028a86ee7b4472fc91e167

RUN apk add -U ca-certificates curl && \
cd /tmp && \
Expand Down
205 changes: 205 additions & 0 deletions test/files/create_alb.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
{
"resource_changes": [
{
"address": "module.alb_test.aws_alb.alb",
"module_address": "module.alb_test",
"mode": "managed",
"type": "aws_alb",
"name": "alb",
"provider_name": "aws",
"change": {
"actions": [
"create"
],
"before": null,
"after": {
"access_logs": [
{
"bucket": "",
"enabled": false,
"prefix": null
}
],
"enable_cross_zone_load_balancing": null,
"enable_deletion_protection": false,
"enable_http2": true,
"idle_timeout": 60,
"internal": true,
"load_balancer_type": "application",
"name": "super-nice-alb-name",
"name_prefix": null,
"subnets": [
"subnet-b46032ec",
"subnet-ba881221",
"subnet-ca4311ef"
],
"tags": null,
"timeouts": null
},
"after_unknown": {
"access_logs": [
{}
],
"arn": true,
"arn_suffix": true,
"dns_name": true,
"id": true,
"ip_address_type": true,
"security_groups": true,
"subnet_mapping": true,
"subnets": [
false,
false,
false
],
"vpc_id": true,
"zone_id": true
}
}
},
{
"address": "module.alb_test.aws_alb_listener.https",
"module_address": "module.alb_test",
"mode": "managed",
"type": "aws_alb_listener",
"name": "https",
"provider_name": "aws",
"change": {
"actions": [
"create"
],
"before": null,
"after": {
"certificate_arn": "",
"default_action": [
{
"authenticate_cognito": [],
"authenticate_oidc": [],
"fixed_response": [],
"redirect": [],
"target_group_arn": "foobar",
"type": "forward"
}
],
"port": 443,
"protocol": "HTTPS",
"timeouts": null
},
"after_unknown": {
"arn": true,
"default_action": [
{
"authenticate_cognito": [],
"authenticate_oidc": [],
"fixed_response": [],
"order": true,
"redirect": []
}
],
"id": true,
"load_balancer_arn": true,
"ssl_policy": true
}
}
},
{
"address": "module.alb_test.aws_security_group.default",
"module_address": "module.alb_test",
"mode": "managed",
"type": "aws_security_group",
"name": "default",
"provider_name": "aws",
"change": {
"actions": [
"create"
],
"before": null,
"after": {
"description": "Managed by Terraform",
"egress": [
{
"cidr_blocks": [
"0.0.0.0/0"
],
"description": "",
"from_port": 0,
"ipv6_cidr_blocks": [],
"prefix_list_ids": [],
"protocol": "-1",
"security_groups": [],
"self": false,
"to_port": 0
}
],
"ingress": [
{
"cidr_blocks": [
"0.0.0.0/0"
],
"description": "",
"from_port": 443,
"ipv6_cidr_blocks": [],
"prefix_list_ids": [],
"protocol": "tcp",
"security_groups": [],
"self": false,
"to_port": 443
},
{
"cidr_blocks": [
"0.0.0.0/0"
],
"description": "",
"from_port": 80,
"ipv6_cidr_blocks": [],
"prefix_list_ids": [],
"protocol": "tcp",
"security_groups": [],
"self": false,
"to_port": 80
}
],
"name_prefix": null,
"revoke_rules_on_delete": false,
"tags": null,
"timeouts": null,
"vpc_id": "foobar"
},
"after_unknown": {
"arn": true,
"egress": [
{
"cidr_blocks": [
false
],
"ipv6_cidr_blocks": [],
"prefix_list_ids": [],
"security_groups": []
}
],
"id": true,
"ingress": [
{
"cidr_blocks": [
false
],
"ipv6_cidr_blocks": [],
"prefix_list_ids": [],
"security_groups": []
},
{
"cidr_blocks": [
false
],
"ipv6_cidr_blocks": [],
"prefix_list_ids": [],
"security_groups": []
}
],
"name": true,
"owner_id": true
}
}
}
]
}
Loading

0 comments on commit 17a6b2b

Please sign in to comment.