Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
arianvp committed Dec 17, 2023
1 parent 1845459 commit 91931d5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
26 changes: 6 additions & 20 deletions .github/workflows/upload-legacy-ami.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,15 @@ jobs:
role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/state
aws-region: ${{ env.AWS_REGION }}

- name: Get S3 bucket name
id: get_bucket_name
run: |
cd tf
nix shell --inputs-from . nixpkgs#opentofu --command ./tofu-init.sh
images_bucket=$(nix shell --inputs-from . nixpkgs#opentofu --command tofu output -raw images_bucket)
echo "images_bucket=$images_bucket" >> "$GITHUB_OUTPUT"
- uses: aws-actions/configure-aws-credentials@010d0da01d0b5a38af31e9c3470dbfdabdecca3a # v4.0.1
with:
role-to-assume: arn:aws:iam::${{ vars.AWS_ACCOUNT_ID }}:role/upload-ami
aws-region: ${{ env.AWS_REGION }}


# NOTE: We do not pass run-id as we're not building the image ourselves
# and we thus need to poll hydra periodically. Including the run-id would
# cause us to register the same snapshot as an image over and over again
# for each run.
- name: Upload Smoke test AMI
id: upload_smoke_test_ami
run: |
image_info="${{ steps.download_ami.outputs.image_info }}"
images_bucket="${{ steps.get_bucket_name.outputs.images_bucket }}"
image_info='${{ steps.download_ami.outputs.image_info }}'
images_bucket='${{ vars.IMAGES_BUCKET }}'
image_ids=$(nix run .#upload-ami -- \
--image-info "$image_info" \
--prefix "staging-legacy/" \
Expand All @@ -74,14 +60,14 @@ jobs:
- name: Smoke test
id: smoke_test
run: |
image_ids="${{ steps.upload_smoke_test_ami.outputs.image_ids }}"
image_id=$(echo "$amis" | jq -r '.["${{ env.AWS_REGION }}"]')
image_ids='${{ steps.upload_smoke_test_ami.outputs.image_ids }}'
image_id=$(echo "$image_ids" | jq -r '.["${{ env.AWS_REGION }}"]')
nix run .#smoke-test -- --image-id "$image_id" --region "${{ env.AWS_REGION }}"
- name: Upload AMIs to all available regions
run: |
image_info="${{ steps.download_ami.outputs.image_info }}"
images_bucket="${{ steps.get_bucket_name.outputs.images_bucket }}"
image_info='${{ steps.download_ami.outputs.image_info }}'
images_bucket='${{ vars.IMAGES_BUCKET }}'
image_ids=$(nix run .#upload-ami -- \
--image-info "$image_info" \
--prefix "legacy/" \
Expand Down
1 change: 1 addition & 0 deletions upload-ami/src/upload_ami/smoke_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

def smoke_test(image_id, region):
ec2 = boto3.client("ec2", region_name=region)
print(image_id)

images = ec2.describe_images(Owners=["self"], ImageIds=[image_id])
assert len(images["Images"]) == 1
Expand Down

0 comments on commit 91931d5

Please sign in to comment.