Skip to content

Commit c6c99d6

Browse files
rsrchboyaknysh
authored andcommitted
Use owners with data.aws_ami.info (#35)
* Use `owners` with `data.aws_ami.info` The latest `terraform-aws-provider` appears to require this, so let's humor it, and either supply it in case we're using the default AMI, or allow the user to provide it. * Update docs/README * ...aand appease `terraform fmt`
1 parent 4257315 commit c6c99d6

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,22 +102,22 @@ Available targets:
102102
lint Lint terraform code
103103
104104
```
105-
106105
## Inputs
107106

108107
| Name | Description | Type | Default | Required |
109108
|------|-------------|:----:|:-----:|:-----:|
110109
| additional_ips_count | Count of additional EIPs | string | `0` | no |
111110
| allowed_ports | List of allowed ingress ports | list | `<list>` | no |
112111
| ami | The AMI to use for the instance. By default it is the AMI provided by Amazon with Ubuntu 16.04 | string | `` | no |
112+
| ami_owner | Owner of the given AMI (ignored if `ami` unset) | string | `` | no |
113113
| applying_period | The period in seconds over which the specified statistic is applied | string | `60` | no |
114114
| assign_eip_address | Assign an Elastic IP address to the instance | string | `true` | no |
115115
| associate_public_ip_address | Associate a public IP address with the instance | string | `true` | no |
116116
| attributes | Additional attributes (e.g. `1`) | list | `<list>` | no |
117117
| availability_zone | Availability Zone the instance is launched in. If not set, will be launched in the first AZ of the region | string | `` | no |
118118
| comparison_operator | The arithmetic operation to use when comparing the specified Statistic and Threshold. Possible values are: GreaterThanOrEqualToThreshold, GreaterThanThreshold, LessThanThreshold, LessThanOrEqualToThreshold. | string | `GreaterThanOrEqualToThreshold` | no |
119119
| create_default_security_group | Create default Security Group with only Egress traffic allowed | string | `true` | no |
120-
| default_alarm_action | | string | `action/actions/AWS_EC2.InstanceId.Reboot/1.0` | no |
120+
| default_alarm_action | - | string | `action/actions/AWS_EC2.InstanceId.Reboot/1.0` | no |
121121
| delete_on_termination | Whether the volume should be destroyed on instance termination | string | `true` | no |
122122
| delimiter | Delimiter to be used between `name`, `namespace`, `stage`, etc. | string | `-` | no |
123123
| disable_api_termination | Enable EC2 Instance Termination Protection | string | `false` | no |
@@ -152,7 +152,7 @@ Available targets:
152152
| tags | Additional tags | map | `<map>` | no |
153153
| user_data | Instance user data. Do not pass gzip-compressed data via this argument | string | `` | no |
154154
| vpc_id | The ID of the VPC that the instance security group belongs to | string | - | yes |
155-
| welcome_message | | string | `` | no |
155+
| welcome_message | - | string | `` | no |
156156

157157
## Outputs
158158

@@ -263,7 +263,7 @@ In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow.
263263

264264
## Copyright
265265

266-
Copyright © 2017-2018 [Cloud Posse, LLC](https://cpco.io/copyright)
266+
Copyright © 2017-2019 [Cloud Posse, LLC](https://cpco.io/copyright)
267267

268268

269269

docs/terraform.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
21
## Inputs
32

43
| Name | Description | Type | Default | Required |
54
|------|-------------|:----:|:-----:|:-----:|
65
| additional_ips_count | Count of additional EIPs | string | `0` | no |
76
| allowed_ports | List of allowed ingress ports | list | `<list>` | no |
87
| ami | The AMI to use for the instance. By default it is the AMI provided by Amazon with Ubuntu 16.04 | string | `` | no |
8+
| ami_owner | Owner of the given AMI (ignored if `ami` unset) | string | `` | no |
99
| applying_period | The period in seconds over which the specified statistic is applied | string | `60` | no |
1010
| assign_eip_address | Assign an Elastic IP address to the instance | string | `true` | no |
1111
| associate_public_ip_address | Associate a public IP address with the instance | string | `true` | no |
1212
| attributes | Additional attributes (e.g. `1`) | list | `<list>` | no |
1313
| availability_zone | Availability Zone the instance is launched in. If not set, will be launched in the first AZ of the region | string | `` | no |
1414
| comparison_operator | The arithmetic operation to use when comparing the specified Statistic and Threshold. Possible values are: GreaterThanOrEqualToThreshold, GreaterThanThreshold, LessThanThreshold, LessThanOrEqualToThreshold. | string | `GreaterThanOrEqualToThreshold` | no |
1515
| create_default_security_group | Create default Security Group with only Egress traffic allowed | string | `true` | no |
16-
| default_alarm_action | | string | `action/actions/AWS_EC2.InstanceId.Reboot/1.0` | no |
16+
| default_alarm_action | - | string | `action/actions/AWS_EC2.InstanceId.Reboot/1.0` | no |
1717
| delete_on_termination | Whether the volume should be destroyed on instance termination | string | `true` | no |
1818
| delimiter | Delimiter to be used between `name`, `namespace`, `stage`, etc. | string | `-` | no |
1919
| disable_api_termination | Enable EC2 Instance Termination Protection | string | `false` | no |
@@ -48,7 +48,7 @@
4848
| tags | Additional tags | map | `<map>` | no |
4949
| user_data | Instance user data. Do not pass gzip-compressed data via this argument | string | `` | no |
5050
| vpc_id | The ID of the VPC that the instance security group belongs to | string | - | yes |
51-
| welcome_message | | string | `` | no |
51+
| welcome_message | - | string | `` | no |
5252

5353
## Outputs
5454

main.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ locals {
66
ebs_iops = "${var.ebs_volume_type == "io1" ? var.ebs_iops : "0"}"
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}"
9+
ami_owner = "${var.ami != "" ? var.ami_owner : data.aws_ami.default.owner_id}"
910
root_volume_type = "${var.root_volume_type != "" ? var.root_volume_type : data.aws_ami.info.root_device_type}"
1011
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)}"
1112
}
@@ -56,6 +57,8 @@ data "aws_ami" "info" {
5657
name = "image-id"
5758
values = ["${local.ami}"]
5859
}
60+
61+
owners = ["${local.ami_owner}"]
5962
}
6063

6164
module "label" {

variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ variable "ami" {
8686
default = ""
8787
}
8888

89+
variable "ami_owner" {
90+
description = "Owner of the given AMI (ignored if `ami` unset)"
91+
default = ""
92+
}
93+
8994
variable "ebs_optimized" {
9095
description = "Launched EC2 instance will be EBS-optimized"
9196
default = "false"

0 commit comments

Comments
 (0)