Skip to content

Commit 741d5cc

Browse files
Merge pull request #213 from wking/implicit-provider-inheritance
modules/aws/ami: Use implicit provider inheritance
2 parents b4f7a04 + b68ac26 commit 741d5cc

File tree

9 files changed

+25
-49
lines changed

9 files changed

+25
-49
lines changed

modules/aws/ami/README.md

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,40 @@
11
# Container Linux AMI Module
22

33
This [Terraform][] [module][] supports `latest` versions for [Container Linux][container-linux] release channels and returns an appropriate [AMI][].
4+
It uses [implicit provider inheritance][implicit-provider-inheritance] to access the [AWS provider][AWS-provider].
45

56
## Example
67

7-
From the module directory:
8+
Set up a `main.tf` with:
9+
10+
```hcl
11+
provider "aws" {
12+
region = "us-east-1"
13+
}
14+
15+
module "ami" {
16+
source = "github.com/openshift/installer//modules/aws/ami"
17+
}
18+
19+
output "ami" {
20+
value = "${module.ami.id}"
21+
}
22+
```
23+
24+
You can set `release_channel` and `release_version` if you need a specific Container Linux install.
25+
26+
Then run:
827

928
```console
1029
$ terraform init
11-
$ terraform apply --var region=us-east-1
12-
$ terraform output id
13-
ami-ab6963d4
14-
$ terraform apply --var region=us-east-1 --var release_channel=alpha
15-
$ terraform output id
16-
ami-985953e7
17-
$ terraform apply --var region=us-east-2 --var release_channel=alpha --var release_version=1814.0.0
18-
$ terraform output id
19-
ami-c25f66a7
30+
$ terraform apply
31+
$ terraform output ami
32+
ami-00cc4337762ba4a52
2033
```
2134

22-
When you're done, clean up by removing the `.terraform` directory created by `init` and the `terraform.tfstate*` files created by `apply`.
23-
2435
[AMI]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AMIs.html
36+
[AWS-provider]: https://www.terraform.io/docs/providers/aws/
2537
[container-linux]: https://coreos.com/os/docs/latest/
38+
[implicit-provider-inheritance]: https://www.terraform.io/docs/modules/usage.html#implicit-provider-inheritance
2639
[module]: https://www.terraform.io/docs/modules/
2740
[Terraform]: https://www.terraform.io/

modules/aws/ami/main.tf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
provider "aws" {
2-
region = "${var.region}"
3-
version = "1.8.0"
4-
}
5-
61
locals {
72
ami_owner = "595879546273"
83
arn = "aws"

modules/aws/ami/variables.tf

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
variable "region" {
2-
type = "string"
3-
4-
description = <<EOF
5-
This is the AWS region.
6-
It is passed through to the Terraform aws provider: https://www.terraform.io/docs/providers/aws/#region
7-
EOF
8-
}
9-
101
variable "release_channel" {
112
type = "string"
123
default = "stable"

modules/aws/master/main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ locals {
55
module "ami" {
66
source = "../ami"
77

8-
region = "${var.region}"
98
release_channel = "${var.container_linux_channel}"
109
release_version = "${var.container_linux_version}"
1110
}

modules/aws/master/variables.tf

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,6 @@ variable "elb_console_id" {
8080
type = "string"
8181
}
8282

83-
variable "region" {
84-
type = "string"
85-
86-
description = <<EOF
87-
This is the AWS region.
88-
It is passed through to the Terraform aws provider: https://www.terraform.io/docs/providers/aws/#region
89-
EOF
90-
}
91-
9283
variable "root_volume_iops" {
9384
type = "string"
9485
default = "100"

modules/aws/worker/main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ locals {
55
module "ami" {
66
source = "../ami"
77

8-
region = "${var.region}"
98
release_channel = "${var.container_linux_channel}"
109
release_version = "${var.container_linux_version}"
1110
}

modules/aws/worker/variables.tf

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,6 @@ variable "extra_tags" {
4848
default = {}
4949
}
5050

51-
variable "region" {
52-
type = "string"
53-
54-
description = <<EOF
55-
This is the AWS region.
56-
It is passed through to the Terraform aws provider: https://www.terraform.io/docs/providers/aws/#region
57-
EOF
58-
}
59-
6051
variable "root_volume_type" {
6152
type = "string"
6253
description = "The type of volume for the root block device."

steps/bootstrap/aws/main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ data "ignition_config" "bootstrap_redirect" {
4242
module "ami" {
4343
source = "../../../modules/aws/ami"
4444

45-
region = "${var.tectonic_aws_region}"
4645
release_channel = "${var.tectonic_container_linux_channel}"
4746
release_version = "${var.tectonic_container_linux_version}"
4847
}

steps/infra/aws/main.tf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ module "masters" {
4242
master_sg_ids = "${concat(var.tectonic_aws_master_extra_sg_ids, list(module.vpc.master_sg_id))}"
4343
private_endpoints = "${local.private_endpoints}"
4444
public_endpoints = "${local.public_endpoints}"
45-
region = "${var.tectonic_aws_region}"
4645
root_volume_iops = "${var.tectonic_aws_master_root_volume_iops}"
4746
root_volume_size = "${var.tectonic_aws_master_root_volume_size}"
4847
root_volume_type = "${var.tectonic_aws_master_root_volume_type}"
@@ -62,7 +61,6 @@ module "workers" {
6261
extra_tags = "${var.tectonic_aws_extra_tags}"
6362
instance_count = "${var.tectonic_worker_count}"
6463
load_balancers = "${var.tectonic_aws_worker_load_balancers}"
65-
region = "${var.tectonic_aws_region}"
6664
root_volume_iops = "${var.tectonic_aws_worker_root_volume_iops}"
6765
root_volume_size = "${var.tectonic_aws_worker_root_volume_size}"
6866
root_volume_type = "${var.tectonic_aws_worker_root_volume_type}"

0 commit comments

Comments
 (0)