forked from openshift/installer
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
modules/aws/ami: Use implicit provider inheritance
Docs in [1], where they say: This approach is recommended in the common case where only a single configuration is needed for each provider across the entire configuration. I didn't know about implicit provider inheritance when I landed the module in b23621f (modules/aws/ami: Add a new module to get CoreOS AMIs, 2018-07-31, openshift#84). We'll probably drop this module soon as we move to Red Hat CoreOS, but I worked up the change while looking for patterns to follow for a bootstrap module. The module source syntax used in the README is documented in [2,3,4], and means "the modules/aws/ami subdirectory of the github.com/openshift/installer repository cloned over HTTPS". [1]: https://www.terraform.io/docs/modules/usage.html#implicit-provider-inheritance [2]: https://www.terraform.io/docs/configuration/modules.html#source [3]: https://www.terraform.io/docs/modules/sources.html#github [4]: https://www.terraform.io/docs/modules/sources.html#modules-in-package-sub-directories
- Loading branch information
Showing
9 changed files
with
25 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,40 @@ | ||
# Container Linux AMI Module | ||
|
||
This [Terraform][] [module][] supports `latest` versions for [Container Linux][container-linux] release channels and returns an appropriate [AMI][]. | ||
It uses [implicit provider inheritance][implicit-provider-inheritance] to access the [AWS provider][AWS-provider]. | ||
|
||
## Example | ||
|
||
From the module directory: | ||
Set up a `main.tf` with: | ||
|
||
```hcl | ||
provider "aws" { | ||
region = "us-east-1" | ||
} | ||
module "ami" { | ||
source = "github.com/openshift/installer//modules/aws/ami" | ||
} | ||
output "ami" { | ||
value = "${module.ami.id}" | ||
} | ||
``` | ||
|
||
You can set `release_channel` and `release_version` if you need a specific Container Linux install. | ||
|
||
Then run: | ||
|
||
```console | ||
$ terraform init | ||
$ terraform apply --var region=us-east-1 | ||
$ terraform output id | ||
ami-ab6963d4 | ||
$ terraform apply --var region=us-east-1 --var release_channel=alpha | ||
$ terraform output id | ||
ami-985953e7 | ||
$ terraform apply --var region=us-east-2 --var release_channel=alpha --var release_version=1814.0.0 | ||
$ terraform output id | ||
ami-c25f66a7 | ||
$ terraform apply | ||
$ terraform output ami | ||
ami-00cc4337762ba4a52 | ||
``` | ||
|
||
When you're done, clean up by removing the `.terraform` directory created by `init` and the `terraform.tfstate*` files created by `apply`. | ||
|
||
[AMI]: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AMIs.html | ||
[AWS-provider]: https://www.terraform.io/docs/providers/aws/ | ||
[container-linux]: https://coreos.com/os/docs/latest/ | ||
[implicit-provider-inheritance]: https://www.terraform.io/docs/modules/usage.html#implicit-provider-inheritance | ||
[module]: https://www.terraform.io/docs/modules/ | ||
[Terraform]: https://www.terraform.io/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,3 @@ | ||
provider "aws" { | ||
region = "${var.region}" | ||
version = "1.8.0" | ||
} | ||
|
||
locals { | ||
ami_owner = "595879546273" | ||
arn = "aws" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters