Skip to content

Instantly share code, notes, and snippets.

@builtroller
Last active April 7, 2022 20:19
Show Gist options
  • Save builtroller/52f2f48c777923527586de0a83c53c78 to your computer and use it in GitHub Desktop.
Save builtroller/52f2f48c777923527586de0a83c53c78 to your computer and use it in GitHub Desktop.

Revisions

  1. builtroller revised this gist Apr 7, 2022. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion ecr_login_makefile.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    # ECR Login with Makefile

    * allow an alias for the aws account id
    * default to the default region for aws

    @@ -7,4 +9,8 @@ make ecr_login

    # login to dev account (111111111111), region = us-west-2
    make ecr_login aws_account=dev region=us-west-2
    ```
    ```

    ## References

    * [Dictionaries/Maps/Lookup Tables in Makefiles](https://stackoverflow.com/a/40919906)
  2. builtroller created this gist Apr 7, 2022.
    11 changes: 11 additions & 0 deletions Makefile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    # map bp/dev to aws account id
    aws_account ?= bp
    aws_account_dev := 111111111111
    aws_account_bp := 222222222222
    aws_account_id := $(aws_account_$(aws_account))

    region ?= $(AWS_DEFAULT_REGION)

    ecr_login:
    aws ecr get-login-password --region $(region) | \
    docker login --username AWS --password-stdin $(aws_account_id).dkr.ecr.$(region).amazonaws.com
    10 changes: 10 additions & 0 deletions ecr_login_makefile.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    * allow an alias for the aws account id
    * default to the default region for aws

    ```bash
    # login to bp account (222222222222), region = AWS_DEFAULT_REGION
    make ecr_login

    # login to dev account (111111111111), region = us-west-2
    make ecr_login aws_account=dev region=us-west-2
    ```