|
1 |
| -# Building AMI |
| 1 | +### Build Cloud Provider Machine Image |
2 | 2 |
|
3 |
| - |
4 |
| -### Requirements |
5 |
| -- [Get Packer](https://www.packer.io/downloads.html) |
6 |
| -- [Packer docs](https://www.packer.io/docs/index.html) |
7 |
| -- [AWS Cli](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html) |
8 |
| -- [AWS API Keys](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html) |
9 |
| -* IAM user should have the following permissions enabled in an IAM Policy for `packer build` to run correctly: |
10 |
| -``` |
11 |
| -{ |
12 |
| - "Version": "2012-10-17", |
13 |
| - "Statement": [ |
14 |
| - { |
15 |
| - "Sid": "PackerEC2", |
16 |
| - "Effect": "Allow", |
17 |
| - "Action": [ |
18 |
| - "ec2:AttachVolume", |
19 |
| - "ec2:AuthorizeSecurityGroupIngress", |
20 |
| - "ec2:CopyImage", |
21 |
| - "ec2:CreateImage", |
22 |
| - "ec2:CreateKeypair", |
23 |
| - "ec2:CreateSecurityGroup", |
24 |
| - "ec2:CreateSnapshot", |
25 |
| - "ec2:CreateTags", |
26 |
| - "ec2:CreateVolume", |
27 |
| - "ec2:DeleteKeypair", |
28 |
| - "ec2:DeleteSecurityGroup", |
29 |
| - "ec2:DeleteSnapshot", |
30 |
| - "ec2:DeleteVolume", |
31 |
| - "ec2:DeregisterImage", |
32 |
| - "ec2:DescribeImageAttribute", |
33 |
| - "ec2:DescribeImages", |
34 |
| - "ec2:DescribeInstances", |
35 |
| - "ec2:DescribeRegions", |
36 |
| - "ec2:DescribeSecurityGroups", |
37 |
| - "ec2:DescribeSnapshots", |
38 |
| - "ec2:DescribeSubnets", |
39 |
| - "ec2:DescribeTags", |
40 |
| - "ec2:DescribeVolumes", |
41 |
| - "ec2:DetachVolume", |
42 |
| - "ec2:GetPasswordData", |
43 |
| - "ec2:ModifyImageAttribute", |
44 |
| - "ec2:ModifyInstanceAttribute", |
45 |
| - "ec2:RegisterImage", |
46 |
| - "ec2:RunInstances", |
47 |
| - "ec2:StopInstances", |
48 |
| - "ec2:TerminateInstances" |
49 |
| - ], |
50 |
| - "Resource": "*" |
51 |
| - } |
52 |
| - ] |
53 |
| -} |
54 |
| -``` |
55 |
| - |
56 |
| - |
57 |
| -### Build Image |
58 |
| -Rename vars.json.sample to vars.json: `$ mv vars.json.sample vars.json` |
59 |
| - |
60 |
| -1. First, edit the var.json file: |
61 |
| -``` |
62 |
| -{ |
63 |
| - "name_prefix": "<what to call your ami>", |
64 |
| - "region": "<region>", |
65 |
| - "ami_regions": "<EC2 Regions to store the AMI in>", |
66 |
| - "profile": "<aws cli profile>", |
67 |
| - "vpc_id": "<your VPC ID>", |
68 |
| - "subnet_id": "<a public subnet in the above VPC>", |
69 |
| - "root_volume_size": "<root volume size in GB>" |
70 |
| - "ami_description": "Description", |
71 |
| - "aws_ssh_username": "admin" |
72 |
| -} |
73 |
| -``` |
74 |
| -example: |
75 |
| -``` |
76 |
| -{ |
77 |
| - "name_prefix": "hiro-private-testnet", |
78 |
| - "region": "us-east-1", |
79 |
| - "ami_regions": "ap-northeast-1,ap-northeast-2,ap-south-1,ap-southeast-1,ap-southeast-2,ca-central-1,eu-central-1,eu-west-1,eu-west-2,eu-west-3,sa-east-1,us-east-1,us-east-2,us-west-1,us-west-2", |
80 |
| - "profile": "default", |
81 |
| - "vpc_id": "vpc-xxxxxxxx", |
82 |
| - "subnet_id": "subnet-xxxxxxxx", |
83 |
| - "root_volume_size": "50", |
84 |
| - "ami_description": "Hiro Private Stacks Testnet", |
85 |
| - "aws_ssh_username": "admin" |
86 |
| -} |
87 |
| -
|
88 |
| -``` |
89 |
| - |
90 |
| -2. Run the packer build process (ex): |
91 |
| -```bash |
92 |
| -$ VERSION=$(curl -sL https://api.github.com/repos/stacks-network/stacks-blockchain/releases/latest | jq .tag_name | tr -d '"') |
93 |
| -$ packer build --var-file=vars.json --var "version=${VERSION}" private-testnet.json |
94 |
| -``` |
| 3 | +Follow the instructions at https://github.com/stacksfoundation/stacks-machine-images |
0 commit comments