Add your AWS credentials as two environment variables, AWS_ACCESS_KEY_ID
and AWS_SECRET_ACCESS_KEY
, replacing <YOUR_ACCESS_KEY>
and <YOUR_SECRET_KEY>
with their respective values.
export AWS_ACCESS_KEY_ID=<YOUR_ACCESS_KEY>
export AWS_SECRET_ACCESS_KEY=<YOUR_SECRET_KEY>
Copy common scripts into place
cp ../../../../scripts/init.sh .
cp ../../../../scripts/kind-load-cafile.sh .
cp ../../../../scripts/inventory.sh .
(Optional) Fetch Tanzu CLI
cp ../../../../scripts/fetch-tanzu-cli.sh .
./fetch-tanzu-cli.sh {VMWUSER} {VMWPASS} linux {TANZU_CLI_VERSION}
Replace
{VMWUSER}
and{VMWPASS}
with credentials you use to authenticate to https://console.cloud.vmware.com. Replace{TANZU_CLI_VERSION}
with a supported (and available) version number for the CLI you wish to embed in the container image. If your account has been granted access, the script will download a tarball, extract the Tanzu CLI and place it into adist
directory. The tarball and other content will be discarded. (The script has "smarts" built-in to determine whether or not to fetch a version of the CLI that may have already been fetched and placed in thedist
directory).
(Optional) Fetch and install oci CLI
cp ../scripts/fetch-and-install-oci-cli.sh .
You're just copying this script into place.
Type the following to build the image
packer init .
packer fmt .
packer validate .
packer inspect .
packer build -only='{BUILD_NAME}.*' .
Replace
{BUILD_NAME}
with one of [standard
,with-tanzu
]; a file provisioner uploads the Tanzu CLI into your image when set towith-tanzu
. You have the option post image build to fetch and install or upgrade it via vmw-cli. The fetch-tanzu-cli.sh script is also packaged and available for your convenience in the resultant image.
In ~10 minutes you should notice a
manifest.json
file where within theartifact_id
contains a reference to the image ID.
You may wish to size the instance and/or choose a different region to host the image.
packer build --var instance_type=m4.xlarge --var vpc_region=eu-west-3 -only='standard.*' .
Consult the
variable
blocks inside ami.pkr.hcl
- Packer and AWS: Tutorial - Build an image
- Amazon EC2 AMI Locator
- Ubuntu 20.04 AMD ebs-ssd images
- us-east-1 - ami-019212a8baeffb0fa
- us-west-2 - ami-02868af3c3df4b3aa
- eu-west-3 - ami-06d3fffafe8d48b35
- Ubuntu 20.04 AMD ebs-ssd images
- Amazon AMI Builder
- AMI Builder (EBS backed)