-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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: Add a new module to get CoreOS AMIs
Centralize this logic, which had previously been copied between three modules. I've also made the AWS region an explicit variable, instead of having the lower level modules reaching up to the tectonic_aws_region global.
- Loading branch information
Showing
14 changed files
with
154 additions
and
72 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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Container Linux AMI Module | ||
|
||
This [Terraform][] [module][] supports `latest` versions for [Container Linux][container-linux] release channels and returns an appropriate [AMI][]. | ||
|
||
## Example | ||
|
||
From the module directory: | ||
|
||
```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 | ||
``` | ||
|
||
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 | ||
[container-linux]: https://coreos.com/os/docs/latest/ | ||
[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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
provider "aws" { | ||
region = "${var.region}" | ||
version = "1.8.0" | ||
} | ||
|
||
locals { | ||
ami_owner = "595879546273" | ||
arn = "aws" | ||
} | ||
|
||
module "container_linux" { | ||
source = "../../container_linux" | ||
|
||
release_channel = "${var.release_channel}" | ||
release_version = "${var.release_version}" | ||
} | ||
|
||
data "aws_ami" "coreos_ami" { | ||
filter { | ||
name = "name" | ||
values = ["CoreOS-${var.release_channel}-${module.container_linux.version}-*"] | ||
} | ||
|
||
filter { | ||
name = "architecture" | ||
values = ["x86_64"] | ||
} | ||
|
||
filter { | ||
name = "virtualization-type" | ||
values = ["hvm"] | ||
} | ||
|
||
filter { | ||
name = "owner-id" | ||
values = ["${local.ami_owner}"] | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
output "id" { | ||
value = "${data.aws_ami.coreos_ami.image_id}" | ||
description = "The selected CoreOS Container Linux AMI ID." | ||
} |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
variable "region" { | ||
type = "string" | ||
|
||
description = <<EOF | ||
This is the AWS region. | ||
It is passed through to the Terraform aws provider: https://www.terraform.io/docs/providers/aws/#region | ||
EOF | ||
} | ||
|
||
variable "release_channel" { | ||
type = "string" | ||
default = "stable" | ||
|
||
description = <<EOF | ||
The Container Linux update channel. | ||
Examples: `stable`, `beta`, `alpha` | ||
EOF | ||
} | ||
|
||
variable "release_version" { | ||
type = "string" | ||
default = "latest" | ||
|
||
description = <<EOF | ||
The Container Linux version to use. Set to `latest` to select the latest available version for the selected update channel. | ||
Examples: `latest`, `1465.6.0` | ||
EOF | ||
} |
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
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