Skip to content

Commit fc2c767

Browse files
SweetOpsaknysh
authored andcommitted
Fix outputs. Update README (#26)
* Fix the public_dns output * Remove deprecated attribute * Update make targets * Fix outputs. Update `README` * Update `README` * Update `README` * Update `README` * Update `README`
1 parent b5ded90 commit fc2c767

File tree

7 files changed

+92
-98
lines changed

7 files changed

+92
-98
lines changed

.travis.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ install:
99
- make init
1010

1111
script:
12-
- make terraform:install
13-
- make terraform:get-plugins
14-
- make terraform:get-modules
15-
- make terraform:lint
16-
- make terraform:validate
12+
- make terraform/install
13+
- make terraform/get-plugins
14+
- make terraform/get-modules
15+
- make terraform/lint
16+
- make terraform/validate

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2017 Cloud Posse, LLC
189+
Copyright 2017-2018 Cloud Posse, LLC
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ SHELL := /bin/bash
33
-include $(shell curl -sSL -o .build-harness "https://git.io/build-harness"; echo .build-harness)
44

55
lint:
6-
$(SELF) terraform:install terraform:get-modules terraform:get-plugins terraform:lint terraform:validate
6+
$(SELF) terraform/install terraform/get-modules terraform/get-plugins terraform/lint terraform/validate

README.md

Lines changed: 64 additions & 66 deletions
Large diffs are not rendered by default.

main.tf

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ locals {
77
availability_zone = "${var.availability_zone != "" ? var.availability_zone : data.aws_subnet.default.availability_zone}"
88
ami = "${var.ami != "" ? var.ami : data.aws_ami.default.image_id}"
99
root_volume_type = "${var.root_volume_type != "" ? var.root_volume_type : data.aws_ami.info.root_device_type}"
10+
public_dns = "${var.associate_public_ip_address == "true" && var.assign_eip_address == "true" && var.instance_enabled == "true" ? data.null_data_source.eip.outputs["public_dns"] : join("", aws_instance.default.*.public_dns)}"
1011
}
1112

1213
data "aws_caller_identity" "default" {}
1314

14-
data "aws_region" "default" {
15-
current = "true"
16-
}
15+
data "aws_region" "default" {}
1716

1817
data "aws_subnet" "default" {
1918
id = "${var.subnet}"
@@ -59,9 +58,8 @@ data "aws_ami" "info" {
5958
}
6059
}
6160

62-
# Apply the tf_label module for this resource
6361
module "label" {
64-
source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.3.1"
62+
source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.3.5"
6563
namespace = "${var.namespace}"
6664
stage = "${var.stage}"
6765
name = "${var.name}"
@@ -122,11 +120,9 @@ resource "aws_eip" "default" {
122120
vpc = "true"
123121
}
124122

125-
resource "null_resource" "eip" {
126-
count = "${var.associate_public_ip_address == "true" && var.assign_eip_address == "true" && var.instance_enabled == "true" ? 1 : 0}"
127-
128-
triggers {
129-
public_dns = "ec2-${replace(aws_eip.default.public_ip, ".", "-")}.${local.region == "us-east-1" ? "compute-1" : "${local.region}.compute"}.amazonaws.com"
123+
data "null_data_source" "eip" {
124+
inputs = {
125+
public_dns = "ec2-${replace(join("", aws_eip.default.*.public_ip), ".", "-")}.${local.region == "us-east-1" ? "compute-1" : "${local.region}.compute"}.amazonaws.com"
130126
}
131127
}
132128

outputs.tf

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
output "public_ip" {
2-
description = "Public IP of instance (or EIP )"
3-
value = "${coalesce(join("", aws_eip.default.*.public_ip), aws_instance.default.public_ip)}"
2+
description = "Public IP of instance (or EIP)"
3+
value = "${coalesce(join("", aws_eip.default.*.public_ip), join("", aws_instance.default.*.public_ip))}"
44
}
55

66
output "private_ip" {
@@ -15,26 +15,26 @@ output "private_dns" {
1515

1616
output "public_dns" {
1717
description = "Public DNS of instance (or DNS of EIP)"
18-
value = "${coalesce(join("", null_resource.eip.*.triggers.public_dns), aws_instance.default.public_dns)}"
18+
value = "${local.public_dns}"
1919
}
2020

2121
output "id" {
22-
description = "Disambiguated ID"
22+
description = "Disambiguated ID of the instance"
2323
value = "${join("", aws_instance.default.*.id)}"
2424
}
2525

2626
output "ssh_key_pair" {
27-
description = "Name of used AWS SSH key"
27+
description = "Name of the SSH key pair provisioned on the instance"
2828
value = "${var.ssh_key_pair}"
2929
}
3030

3131
output "security_group_ids" {
32-
description = "ID on the new AWS Security Group associated with creating instance"
32+
description = "IDs on the AWS Security Groups associated with the instance"
3333
value = "${compact(concat(list(var.create_default_security_group == "true" ? join("", aws_security_group.default.*.id) : ""), var.security_groups))}"
3434
}
3535

3636
output "role" {
37-
description = "Name of AWS IAM Role associated with creating instance"
37+
description = "Name of AWS IAM Role associated with the instance"
3838
value = "${join("", aws_iam_role.default.*.name)}"
3939
}
4040

@@ -44,21 +44,21 @@ output "alarm" {
4444
}
4545

4646
output "additional_eni_ids" {
47-
description = "Map of ENI with EIP"
47+
description = "Map of ENI to EIP"
4848
value = "${zipmap(aws_network_interface.additional.*.id, aws_eip.additional.*.public_ip)}"
4949
}
5050

5151
output "ebs_ids" {
52-
description = "ID of EBSs"
52+
description = "IDs of EBSs"
5353
value = "${aws_ebs_volume.default.*.id}"
5454
}
5555

5656
output "primary_network_interface_id" {
5757
description = "ID of the instance's primary network interface"
58-
value = "${aws_instance.default.primary_network_interface_id}"
58+
value = "${join("", aws_instance.default.*.primary_network_interface_id)}"
5959
}
6060

6161
output "network_interface_id" {
6262
description = "ID of the network interface that was created with the instance"
63-
value = "${aws_instance.default.network_interface_id}"
63+
value = "${join("", aws_instance.default.*.network_interface_id)}"
6464
}

variables.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,23 @@ variable "subnet" {
4343
}
4444

4545
variable "namespace" {
46-
description = "Namespace (e.g. `cp` or `cloudposse`) - required for `tf_label` module"
46+
description = "Namespace (e.g. `cp` or `cloudposse`)"
4747
}
4848

4949
variable "stage" {
50-
description = "Stage (e.g. `prod`, `dev`, `staging` - required for `tf_label` module"
50+
description = "Stage (e.g. `prod`, `dev`, `staging`"
5151
}
5252

5353
variable "name" {
54-
description = "Name (e.g. `bastion` or `db`) - required for `tf_label` module"
54+
description = "Name (e.g. `bastion` or `db`)"
5555
}
5656

5757
variable "delimiter" {
5858
default = "-"
5959
}
6060

6161
variable "attributes" {
62-
description = "Additional attributes (e.g. `policy` or `role`)"
62+
description = "Additional attributes (e.g. `1`)"
6363
type = "list"
6464
default = []
6565
}

0 commit comments

Comments
 (0)