Skip to content

Commit 575898f

Browse files
Sean Smithsean-smith
authored andcommitted
GovCloud Changes
Signed-off-by: Sean Smith <seaam@amazon.com>
1 parent 492517a commit 575898f

File tree

6 files changed

+79
-23
lines changed

6 files changed

+79
-23
lines changed

amis/build_ami.sh

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,20 @@
1313
#
1414
# Usage: build_ami.sh <os> <region> [private|public] [<build-date>]
1515
# os: the os to build (supported values: all|centos6|centos7|alinux|ubuntu1404|ubuntu1604)
16-
# region: region to build (supported values: all|us-east-1|...)
16+
# partition: partition to build in (supported values: commercial|govcloud)
17+
# region: region to copy ami too (supported values: all|us-east-1|us-gov-west-1|...)
1718
# private|public: specifies AMIs visibility (optional, default is private)
1819
# build-date: timestamp to append to the AMIs names (optional)
1920

2021
set -e
2122

2223
os=$1
23-
region=$2
24-
public=$3
25-
build_date=$4
24+
partition=$2
25+
region=$3
26+
public=$4
27+
build_date=$5
2628

2729
available_os="centos6 centos7 alinux ubuntu1404 ubuntu1604"
28-
available_regions="$(aws ec2 --region us-east-1 describe-regions --query Regions[].RegionName --output text | tr '\t' ',')"
2930
cwd="$(dirname $0)"
3031
export VENDOR_PATH="${cwd}/../../vendor/cookbooks"
3132

@@ -36,17 +37,27 @@ if [ "x${os}" == "x" ]; then
3637
fi
3738

3839
if [ "x${region}" == "x" ]; then
39-
echo "Must provide AWS region to build for."
40-
echo "Options: us-east-1 all"
40+
echo "Must provide AWS region to copy ami into"
41+
echo "Options: all us-east-1 us-gov-west-1 ..."
4142
exit 1
4243
fi
4344

4445
if [ "${public}" == "public" ]; then
4546
export AMI_PERMS="all"
4647
fi
4748

48-
# NOTE: the AMI is always built in us-east-1 and then copied to the specified regions
49+
if [ "${partition}" == "commercial" ]; then
50+
export AWS_REGION="us-east-1"
51+
elif [ "${partition}" == "govcloud" ]; then
52+
export AWS_REGION="us-gov-west-1"
53+
else
54+
echo "Must provide AWS partition to build for."
55+
echo "Options: commercial govcloud"
56+
exit 1
57+
fi
58+
4959
if [ "${region}" == "all" ]; then
60+
available_regions="$(aws ec2 --region ${AWS_REGION} describe-regions --query Regions[].RegionName --output text | tr '\t' ',')"
5061
export BUILD_FOR=${available_regions}
5162
else
5263
export BUILD_FOR=${region}

amis/packer_alinux.json

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,22 @@
1313
"instance_type" : "{{env `AWS_FLAVOR_ID`}}",
1414
"subnet_id" : "{{env `AWS_SUBNET_ID`}}",
1515
"vpc_id" : "{{env `AWS_VPC_ID`}}",
16-
"ami_name_prefix" : "{{env `AMI_NAME_PREFIX`}}"
16+
"ami_name_prefix" : "{{env `AMI_NAME_PREFIX`}}",
17+
"region" : "{{env `AWS_REGION`}}"
1718
},
1819
"builders" : [
1920
{
2021
"type" : "amazon-ebs",
21-
"region" : "us-east-1",
22-
"source_ami" : "ami-55ef662f",
22+
"region" : "{{user `region`}}",
23+
"source_ami_filter": {
24+
"filters": {
25+
"virtualization-type": "hvm",
26+
"name": "amzn-ami-hvm-*.*.*.*-x86_64-gp2",
27+
"root-device-type": "ebs",
28+
"owner-alias": "amazon"
29+
},
30+
"most_recent": true
31+
},
2332
"ami_regions" : "{{user `build_for`}}",
2433
"ami_groups" : "{{user `ami_perms`}}",
2534
"instance_type" : "{{user `instance_type`}}",

amis/packer_centos6.json

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,22 @@
1313
"instance_type" : "{{env `AWS_FLAVOR_ID`}}",
1414
"subnet_id" : "{{env `AWS_SUBNET_ID`}}",
1515
"vpc_id" : "{{env `AWS_VPC_ID`}}",
16-
"ami_name_prefix" : "{{env `AMI_NAME_PREFIX`}}"
16+
"ami_name_prefix" : "{{env `AMI_NAME_PREFIX`}}",
17+
"region" : "{{env `AWS_REGION`}}"
1718
},
1819
"builders" : [
1920
{
2021
"type" : "amazon-ebs",
21-
"region" : "us-east-1",
22-
"source_ami" : "ami-44f1aa3e",
22+
"region" : "{{user `region`}}",
23+
"source_ami_filter": {
24+
"filters": {
25+
"virtualization-type": "hvm",
26+
"name": "CentOS 6.x x86_64 - minimal with cloud-init - *",
27+
"root-device-type": "ebs"
28+
},
29+
"owners": ["247102896272"],
30+
"most_recent": true
31+
},
2332
"ami_regions" : "{{user `build_for`}}",
2433
"ami_groups" : "{{user `ami_perms`}}",
2534
"instance_type" : "{{user `instance_type`}}",

amis/packer_centos7.json

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,22 @@
1313
"instance_type" : "{{env `AWS_FLAVOR_ID`}}",
1414
"subnet_id" : "{{env `AWS_SUBNET_ID`}}",
1515
"vpc_id" : "{{env `AWS_VPC_ID`}}",
16-
"ami_name_prefix" : "{{env `AMI_NAME_PREFIX`}}"
16+
"ami_name_prefix" : "{{env `AMI_NAME_PREFIX`}}",
17+
"region" : "{{env `AWS_REGION`}}"
1718
},
1819
"builders" : [
1920
{
2021
"type" : "amazon-ebs",
21-
"region" : "us-east-1",
22-
"source_ami" : "ami-06fea57c",
22+
"region" : "{{user `region`}}",
23+
"source_ami_filter": {
24+
"filters": {
25+
"virtualization-type": "hvm",
26+
"name": "CentOS 7.x x86_64 - minimal with cloud-init - *",
27+
"root-device-type": "ebs"
28+
},
29+
"owners": ["247102896272"],
30+
"most_recent": true
31+
},
2332
"ami_regions" : "{{user `build_for`}}",
2433
"ami_groups" : "{{user `ami_perms`}}",
2534
"instance_type" : "{{user `instance_type`}}",

amis/packer_ubuntu1404.json

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,24 @@
1313
"instance_type" : "{{env `AWS_FLAVOR_ID`}}",
1414
"subnet_id" : "{{env `AWS_SUBNET_ID`}}",
1515
"vpc_id" : "{{env `AWS_VPC_ID`}}",
16-
"ami_name_prefix" : "{{env `AMI_NAME_PREFIX`}}"
16+
"ami_name_prefix" : "{{env `AMI_NAME_PREFIX`}}",
17+
"region" : "{{env `AWS_REGION`}}"
1718
},
1819
"builders" : [
1920
{
2021
"type" : "amazon-ebs",
21-
"region" : "us-east-1",
22+
"region" : "{{user `region`}}",
23+
"source_ami_filter": {
24+
"filters": {
25+
"virtualization-type": "hvm",
26+
"name": "ubuntu/images/hvm-ssd/ubuntu-trusty-14.04-amd64-server-*",
27+
"root-device-type": "ebs"
28+
},
29+
"owners": ["099720109477", "513442679011"],
30+
"most_recent": true
31+
},
2232
"ami_regions" : "{{user `build_for`}}",
2333
"ami_groups" : "{{user `ami_perms`}}",
24-
"source_ami" : "ami-c29e1cb8",
2534
"instance_type" : "{{user `instance_type`}}",
2635
"ssh_username" : "ubuntu",
2736
"ssh_pty" : true,

amis/packer_ubuntu1604.json

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,24 @@
1313
"instance_type" : "{{env `AWS_FLAVOR_ID`}}",
1414
"subnet_id" : "{{env `AWS_SUBNET_ID`}}",
1515
"vpc_id" : "{{env `AWS_VPC_ID`}}",
16-
"ami_name_prefix" : "{{env `AMI_NAME_PREFIX`}}"
16+
"ami_name_prefix" : "{{env `AMI_NAME_PREFIX`}}",
17+
"region" : "{{env `AWS_REGION`}}"
1718
},
1819
"builders" : [
1920
{
2021
"type" : "amazon-ebs",
21-
"region" : "us-east-1",
22+
"region" : "{{user `region`}}",
23+
"source_ami_filter": {
24+
"filters": {
25+
"virtualization-type": "hvm",
26+
"name": "ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-*",
27+
"root-device-type": "ebs"
28+
},
29+
"owners": ["099720109477", "513442679011"],
30+
"most_recent": true
31+
},
2232
"ami_regions" : "{{user `build_for`}}",
2333
"ami_groups" : "{{user `ami_perms`}}",
24-
"source_ami" : "ami-aa2ea6d0",
2534
"instance_type" : "{{user `instance_type`}}",
2635
"ssh_username" : "ubuntu",
2736
"ssh_pty" : true,

0 commit comments

Comments
 (0)