Skip to content

Commit

Permalink
build: add targets to make built AMIs public or private
Browse files Browse the repository at this point in the history
Co-authored-by: Zac Mrowicki <mrowicki@amazon.com>
Co-authored-by: Tom Kirchner <tjk@amazon.com>
  • Loading branch information
zmrow and tjkirch committed Aug 18, 2020
1 parent d5fa362 commit 58d03cf
Show file tree
Hide file tree
Showing 4 changed files with 533 additions and 2 deletions.
58 changes: 58 additions & 0 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,64 @@ ln -snf "../${ami_output##*/}" "${ami_output_latest}"
'''
]

[tasks.ami-public]
# Rather than depend on "build", which currently rebuilds images each run, we
# depend on publish-tools and check for the input file below to save time.
# This does mean that `cargo make ami` must be run before `cargo make ami-public`.
dependencies = ["publish-tools"]
script_runner = "bash"
script = [
'''
set -e
export PATH="${BUILDSYS_TOOLS_DIR}/bin:${PATH}"
ami_input="${BUILDSYS_OUTPUT_DIR}/${BUILDSYS_NAME_FULL}-amis.json"
if [ ! -s "${ami_input}" ]; then
echo "AMI input file doesn't exist for the current version/commit - ${BUILDSYS_VERSION_FULL} - please run 'cargo make ami'" >&2
exit 1
fi
pubsys \
--infra-config-path "${PUBLISH_INFRA_CONFIG_PATH}" \
\
publish-ami \
--make-public \
\
--ami-input "${ami_input}" \
${PUBLISH_REGIONS:+--regions "${PUBLISH_REGIONS}"}
'''
]

[tasks.ami-private]
# Rather than depend on "build", which currently rebuilds images each run, we
# depend on publish-tools and check for the input file below to save time.
# This does mean that `cargo make ami` must be run before `cargo make ami-private`.
dependencies = ["publish-tools"]
script_runner = "bash"
script = [
'''
set -e
export PATH="${BUILDSYS_TOOLS_DIR}/bin:${PATH}"
ami_input="${BUILDSYS_OUTPUT_DIR}/${BUILDSYS_NAME_FULL}-amis.json"
if [ ! -s "${ami_input}" ]; then
echo "AMI input file doesn't exist for the current version/commit - ${BUILDSYS_VERSION_FULL} - please run 'cargo make ami'" >&2
exit 1
fi
pubsys \
--infra-config-path "${PUBLISH_INFRA_CONFIG_PATH}" \
\
publish-ami \
--make-private \
\
--ami-input "${ami_input}" \
${PUBLISH_REGIONS:+--regions "${PUBLISH_REGIONS}"}
'''
]

[tasks.clean]
script_runner = "bash"
script = [
Expand Down
1 change: 1 addition & 0 deletions tools/pubsys/src/aws/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use snafu::ResultExt;
pub(crate) mod client;

pub(crate) mod ami;
pub(crate) mod publish_ami;

/// Builds a Region from the given region name, and uses the custom endpoint from the AWS config,
/// if specified in aws.region.REGION.endpoint.
Expand Down
Loading

0 comments on commit 58d03cf

Please sign in to comment.