Skip to content
This repository has been archived by the owner on Oct 3, 2024. It is now read-only.

Commit

Permalink
Use zarf vars directly in ECR bootstrap script
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Rodriguez committed Oct 6, 2023
1 parent c3b3991 commit f909f5a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
12 changes: 6 additions & 6 deletions hack/ecr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ REPO_NAME="defenseunicorns/pepr/controller"
ECR_CMD="ecr"

# Validate the input for registry type
if [ "$REGISTRY_TYPE" != "public" ] && [ "$REGISTRY_TYPE" != "private" ]; then
if [ "$ZARF_VAR_REGISTRY_TYPE" != "public" ] && [ "$ZARF_VAR_REGISTRY_TYPE" != "private" ]; then
echo "Error: Invalid registry type. Please specify 'public' or 'private'."
exit 1
fi

# When authenticating to a public registry, always authenticate to the us-east-1 region when using the AWS CLI.
# https://docs.aws.amazon.com/AmazonECR/latest/public/public-registries.html#public-registry-auth
if [ "$REGISTRY_TYPE" = "public" ]; then
if [ "$ZARF_VAR_REGISTRY_TYPE" = "public" ]; then

if [ "$AWS_REGION" != "us-east-1" ]; then
if [ "$ZARF_VAR_AWS_REGION" != "us-east-1" ]; then
echo "Error: Invalid region: ECR public registries are only available in the us-east-1 region."
exit 1
fi
Expand All @@ -24,11 +24,11 @@ fi
# Create an ECR repository for the Pepr controller image if it doesn't already exist
if ! aws "$ECR_CMD" describe-repositories \
--repository-names "$REPO_NAME" \
--region "$AWS_REGION" >/dev/null 2>&1
--region "$ZARF_VAR_AWS_REGION" >/dev/null 2>&1
then
ARGS=("--repository-name" "$REPO_NAME" "--region" "$AWS_REGION")
ARGS=("--repository-name" "$REPO_NAME" "--region" "$ZARF_VAR_AWS_REGION")

if [ "$REGISTRY_TYPE" = "private" ]; then
if [ "$ZARF_VAR_REGISTRY_TYPE" = "private" ]; then
ARGS+=("--image-scanning-configuration" "scanOnPush=true" "--image-tag-mutability" "IMMUTABLE")
fi

Expand Down
5 changes: 1 addition & 4 deletions zarf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ components:
actions:
onDeploy:
after:
- cmd: |
export REGISTRY_TYPE="$ZARF_VAR_REGISTRY_TYPE";
export AWS_REGION="$ZARF_VAR_AWS_REGION";
./hack/ecr.sh
- cmd: ./hack/ecr.sh
description: "Create ECR repository for the Pepr controller image"

- name: ecr-hook
Expand Down

0 comments on commit f909f5a

Please sign in to comment.