1. orbies/aws-ecr@1.2.1

orbies/aws-ecr@1.2.1

Sections
Build images and push them to the Amazon Elastic Container Registry.
Created: April 23, 2021Version Published: April 26, 2021Releases: 9
Org Usage:
< 25

Orb Quick Start Guide

Use CircleCI version 2.1 at the top of your .circleci/config.yml file.

1 version: 2.1

Add the orbs stanza below your version, invoking the orb:

1 2 orbs: aws-ecr: orbies/aws-ecr@1.2.1

Use aws-ecr elements in your existing workflows and jobs.

Opt-in to use of uncertified orbs on your organization’s Security settings page.

Usage Examples

simple-build-and-push

Log into AWS, build and push image to Amazon ECR

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 orbs: aws-ecr: circleci/aws-ecr@x.y.z version: 2.1 workflows: build_and_push_image: jobs: - aws-ecr/build-and-push-image: account-url: AWS_ECR_ACCOUNT_URL_ENV_VAR_NAME aws-access-key-id: ACCESS_KEY_ID_ENV_VAR_NAME aws-secret-access-key: SECRET_ACCESS_KEY_ENV_VAR_NAME context: myContext create-repo: true dockerfile: myDockerfile no-output-timeout: 20m path: pathToMyDockerfile profile-name: myProfileName region: AWS_REGION_ENV_VAR_NAME repo: myECRRepository skip-when-tags-exist: false tag: latest,myECRRepoTag

simple-push-helm-chart

Log into AWS and push Helm Chart to Amazon ECR

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 orbs: aws-ecr: circleci/aws-ecr@x.y.z version: 2.1 workflows: build_and_push_image: jobs: - aws-ecr/build-and-push-image: account-url: AWS_ECR_ACCOUNT_URL_ENV_VAR_NAME aws-access-key-id: ACCESS_KEY_ID_ENV_VAR_NAME aws-secret-access-key: SECRET_ACCESS_KEY_ENV_VAR_NAME context: myContext create-repo: true path: pathToMyHelmChart profile-name: myProfileName region: AWS_REGION_ENV_VAR_NAME repo: myECRRepository tag: 1.0.0

Jobs

build-and-push-image

Install AWS CLI, if needed, and configure. Log into Amazon ECR and push image to repository. Requires environment variables for AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. We recommend these be saved in a Project (https://circleci.com/docs/2.0/env-vars/#setting-an-environment-variable-in-a-project) or in Contexts (https://circleci.com/docs/2.0/contexts).

Show job Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
account-url
Env var storing Amazon ECR account URL that maps to an AWS account, e.g. {awsAccountNum}.dkr.ecr.us-west-2.amazonaws.com defaults to AWS_ECR_ACCOUNT_URL
No
AWS_ECR_ACCOUNT_URL
env_var_name
attach-workspace
Boolean for whether or not to attach to an existing workspace. Default is false.
No
false
boolean
aws-access-key-id
AWS access key id for IAM role. Set this to the name of the environment variable you will set to hold this value, i.e. AWS_ACCESS_KEY_ID.
No
AWS_ACCESS_KEY_ID
env_var_name
aws-secret-access-key
AWS secret key for IAM role. Set this to the name of the environment variable you will set to hold this value, i.e. AWS_SECRET_ACCESS_KEY.
No
AWS_SECRET_ACCESS_KEY
env_var_name
checkout
Boolean for whether or not to checkout as a first step. Default is true.
No
true
boolean
create-repo
Should the repo be created if it does not exist?
No
false
boolean
docker-login
Enable dockerhub authentication. Defaults to false.
No
false
boolean
dockerfile
Name of dockerfile to use. Defaults to Dockerfile.
No
Dockerfile
string
dockerhub-password
Dockerhub password to be configured. Set this to the name of the environment variable you will set to hold this value, i.e. DOCKERHUB_PASSWORD.
No
DOCKERHUB_PASSWORD
env_var_name
dockerhub-username
Dockerhub username to be configured. Set this to the name of the environment variable you will set to hold this value, i.e. DOCKERHUB_USERNAME.
No
DOCKERHUB_USERNAME
env_var_name
executor
executor to use for this job
No
default
executor
extra-build-args
Extra flags to pass to docker build. For examples, see https://docs.docker.com/engine/reference/commandline/build
No
''
string
no-output-timeout
The amount of time to allow the docker build command to run before timing out. Defaults to '10m'
No
10m
string
path
Path to the directory containing your Dockerfile and build context. Defaults to . (working directory).
No
.
string
profile-name
AWS profile name to be configured.
No
default
string
region
Name of env var storing your AWS region information, defaults to AWS_REGION
No
AWS_REGION
env_var_name
remote-docker-layer-caching
Enable Docker layer caching if using remote Docker engine. Defaults to false.
No
false
boolean
remote-docker-version
Specific remote docker version
No
19.03.13
string
repo
Name of an Amazon ECR repository
Yes
-
string
setup-remote-docker
Setup and use CircleCI's remote Docker environment for Docker and docker-compose commands? Not required if using the default executor
No
false
boolean
skip-when-tags-exist
Whether to skip image building if all specified tags already exist in ECR
No
false
boolean
tag
A comma-separated string containing docker image tags to build and push (default = latest)
No
latest
string
workspace-root
Workspace root path that is either an absolute path or a path relative to the working directory. Defaults to '.' (the working directory)
No
.
string

push-helm-chart

Install AWS CLI and Helm, if needed, and configure. Log into Amazon ECR and push helm chart to repository. Requires environment variables for AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. We recommend these be saved in a Project (https://circleci.com/docs/2.0/env-vars/#setting-an-environment-variable-in-a-project) or in Contexts (https://circleci.com/docs/2.0/contexts).

Show job Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
account-url
Env var storing Amazon ECR account URL that maps to an AWS account, e.g. {awsAccountNum}.dkr.ecr.us-west-2.amazonaws.com defaults to AWS_ECR_ACCOUNT_URL
No
AWS_ECR_ACCOUNT_URL
env_var_name
attach-workspace
Boolean for whether or not to attach to an existing workspace. Default is false.
No
false
boolean
aws-access-key-id
AWS access key id for IAM role. Set this to the name of the environment variable you will set to hold this value, i.e. AWS_ACCESS_KEY_ID.
No
AWS_ACCESS_KEY_ID
env_var_name
aws-secret-access-key
AWS secret key for IAM role. Set this to the name of the environment variable you will set to hold this value, i.e. AWS_SECRET_ACCESS_KEY.
No
AWS_SECRET_ACCESS_KEY
env_var_name
checkout
Boolean for whether or not to checkout as a first step. Default is true.
No
true
boolean
create-repo
Should the repo be created if it does not exist?
No
false
boolean
executor
executor to use for this job
No
default
executor
path
Path to the directory containing your Chart and build context. Defaults to . (working directory).
No
.
string
profile-name
AWS profile name to be configured.
No
default
string
region
Name of env var storing your AWS region information, defaults to AWS_REGION
No
AWS_REGION
env_var_name
repo
Name of an Amazon ECR repository
Yes
-
string
tag
A string containing helm chart tag to push (default = latest)
No
latest
string
workspace-root
Workspace root path that is either an absolute path or a path relative to the working directory. Defaults to '.' (the working directory)
No
.
string

Commands

build-and-push-image

Install AWS CLI, if needed, and configure. Log into Amazon ECR and push image to repository. Requires environment variables for AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. We recommend these be saved in a Project (https://circleci.com/docs/2.0/env-vars/#setting-an-environment-variable-in-a-project) or in Contexts (https://circleci.com/docs/2.0/contexts).

Show command Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
account-url
Env var storing Amazon ECR account URL that maps to an AWS account, e.g. {awsAccountNum}.dkr.ecr.us-west-2.amazonaws.com defaults to AWS_ECR_ACCOUNT_URL
No
AWS_ECR_ACCOUNT_URL
env_var_name
attach-workspace
Boolean for whether or not to attach to an existing workspace. Default is false.
No
false
boolean
aws-access-key-id
AWS access key id for IAM role. Set this to the name of the environment variable you will set to hold this value, i.e. AWS_ACCESS_KEY.
No
AWS_ACCESS_KEY_ID
env_var_name
aws-secret-access-key
AWS secret key for IAM role. Set this to the name of the environment variable you will set to hold this value, i.e. AWS_SECRET_ACCESS_KEY.
No
AWS_SECRET_ACCESS_KEY
env_var_name
checkout
Boolean for whether or not to checkout as a first step. Default is true.
No
true
boolean
create-repo
Should the repo be created if it does not exist?
No
false
boolean
docker-login
Enable dockerhub authentication. Defaults to false.
No
false
boolean
dockerfile
Name of dockerfile to use. Defaults to Dockerfile.
No
Dockerfile
string
dockerhub-password
Dockerhub password to be configured. Set this to the name of the environment variable you will set to hold this value, i.e. DOCKERHUB_PASSWORD.
No
DOCKERHUB_PASSWORD
env_var_name
dockerhub-username
Dockerhub username to be configured. Set this to the name of the environment variable you will set to hold this value, i.e. DOCKERHUB_USERNAME.
No
DOCKERHUB_USERNAME
env_var_name
executor
executor to use for this job
No
default
executor
extra-build-args
Extra flags to pass to docker build. For examples, see https://docs.docker.com/engine/reference/commandline/build
No
''
string
no-output-timeout
The amount of time to allow the docker build command to run before timing out (default is `10m`)
No
10m
string
path
Path to the directory containing your Dockerfile and build context. Defaults to . (working directory).
No
.
string
profile-name
AWS profile name to be configured.
No
default
string
region
Name of env var storing your AWS region information, defaults to AWS_REGION
No
AWS_REGION
env_var_name
remote-docker-layer-caching
Enable Docker layer caching if using remote Docker engine. Defaults to false.
No
false
boolean
remote-docker-version
Specific remote docker version
No
19.03.13
string
repo
Name of an Amazon ECR repository
Yes
-
string
repo-scan-on-push
Should the created repo be security scanned on push?
No
true
boolean
setup-remote-docker
Setup and use CircleCI's remote Docker environment for Docker and docker-compose commands? Not required if using the default executor
No
false
boolean
skip-when-tags-exist
Whether to skip image building if all specified tags already exist in ECR
No
false
boolean
tag
A comma-separated string containing docker image tags to build and push (default = latest)
No
latest
string
workspace-root
Workspace root path that is either an absolute path or a path relative to the working directory. Defaults to '.' (the working directory)
No
.
string

build-image

Build a docker image

Show command Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
account-url
The Amazon ECR account URL that maps to an AWS account, e.g. {awsAccountNum}.dkr.ecr.us-west-2.amazonaws.com
No
AWS_ECR_ACCOUNT_URL
env_var_name
aws-access-key-id
AWS access key id for IAM role. Set this to the name of the environment variable you will set to hold this value, i.e. AWS_ACCESS_KEY.
No
AWS_ACCESS_KEY_ID
env_var_name
aws-secret-access-key
AWS secret key for IAM role. Set this to the name of the environment variable you will set to hold this value, i.e. AWS_SECRET_ACCESS_KEY.
No
AWS_SECRET_ACCESS_KEY
env_var_name
checkout
Boolean for whether or not to checkout as a first step. Default is false.
No
false
boolean
dockerfile
Name of dockerfile to use. Defaults to Dockerfile.
No
Dockerfile
string
ecr-login
Boolean for whether or not to log in to ECR before building. Default is false.
No
false
boolean
extra-build-args
Extra flags to pass to docker build. For examples, see https://docs.docker.com/engine/reference/commandline/build
No
''
string
no-output-timeout
The amount of time to allow the docker command to run before timing out.
No
10m
string
path
Path to the directory containing your Dockerfile and build context. Defaults to . (working directory).
No
.
string
profile-name
AWS profile name to be configured. Only required when skip-when-tags-exist or ecr-login are set to true.
No
default
string
region
Name of env var storing your AWS region information, defaults to AWS_REGION. Only required when skip-when-tags-exist or ecr-login are set to true.
No
AWS_REGION
env_var_name
repo
Name of an Amazon ECR repository
Yes
-
string
skip-when-tags-exist
Whether to skip image building if all specified tags already exist in ECR
No
false
boolean
tag
A comma-separated string containing docker image tags (default = latest)
No
latest
string

docker-ecr-login

Authenticate docker into the Amazon ECR service

Show command Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
account-url
Env var storing Amazon ECR account URL that maps to an AWS account, e.g. {awsAccountNum}.dkr.ecr.us-west-2.amazonaws.com defaults to AWS_ECR_ACCOUNT_URL
No
AWS_ECR_ACCOUNT_URL
env_var_name
aws-access-key-id
AWS access key id for IAM role. Set this to the name of the environment variable you will set to hold this value, i.e. AWS_ACCESS_KEY.
No
AWS_ACCESS_KEY_ID
env_var_name
aws-secret-access-key
AWS secret key for IAM role. Set this to the name of the environment variable you will set to hold this value, i.e. AWS_SECRET_ACCESS_KEY.
No
AWS_SECRET_ACCESS_KEY
env_var_name
profile-name
AWS profile name to be configured. defaults to "default"
No
default
string
region
Name of env var storing your AWS region information, defaults to AWS_REGION
No
AWS_REGION
env_var_name

helm-ecr-login

Authenticate helm into the Amazon ECR service

Show command Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
account-url
Env var storing Amazon ECR account URL that maps to an AWS account, e.g. {awsAccountNum}.dkr.ecr.us-west-2.amazonaws.com defaults to AWS_ECR_ACCOUNT_URL
No
AWS_ECR_ACCOUNT_URL
env_var_name
aws-access-key-id
AWS access key id for IAM role. Set this to the name of the environment variable you will set to hold this value, i.e. AWS_ACCESS_KEY.
No
AWS_ACCESS_KEY_ID
env_var_name
aws-secret-access-key
AWS secret key for IAM role. Set this to the name of the environment variable you will set to hold this value, i.e. AWS_SECRET_ACCESS_KEY.
No
AWS_SECRET_ACCESS_KEY
env_var_name
helm-version
Helm version to install, .e.g. v3.2.4.
No
v3.2.4
string
profile-name
AWS profile name to be configured. defaults to "default"
No
default
string
region
Name of env var storing your AWS region information, defaults to AWS_REGION
No
AWS_REGION
env_var_name

login-and-push-helm-chart

Install AWS CLI and Helm, if needed, and configure. Log into Amazon ECR and push Helm chart to repository. Requires environment variables for AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. We recommend these be saved in a Project (https://circleci.com/docs/2.0/env-vars/#setting-an-environment-variable-in-a-project) or in Contexts (https://circleci.com/docs/2.0/contexts).

Show command Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
account-url
Env var storing Amazon ECR account URL that maps to an AWS account, e.g. {awsAccountNum}.dkr.ecr.us-west-2.amazonaws.com defaults to AWS_ECR_ACCOUNT_URL
No
AWS_ECR_ACCOUNT_URL
env_var_name
attach-workspace
Boolean for whether or not to attach to an existing workspace. Default is false.
No
false
boolean
aws-access-key-id
AWS access key id for IAM role. Set this to the name of the environment variable you will set to hold this value, i.e. AWS_ACCESS_KEY.
No
AWS_ACCESS_KEY_ID
env_var_name
aws-secret-access-key
AWS secret key for IAM role. Set this to the name of the environment variable you will set to hold this value, i.e. AWS_SECRET_ACCESS_KEY.
No
AWS_SECRET_ACCESS_KEY
env_var_name
checkout
Boolean for whether or not to checkout as a first step. Default is true.
No
true
boolean
create-repo
Should the repo be created if it does not exist?
No
false
boolean
executor
executor to use for this job
No
default
executor
path
Path to the directory containing your Helm chart and build context. Defaults to . (working directory).
No
.
string
profile-name
AWS profile name to be configured.
No
default
string
region
Name of env var storing your AWS region information, defaults to AWS_REGION
No
AWS_REGION
env_var_name
repo
Name of an Amazon ECR repository
Yes
-
string
repo-scan-on-push
Should the created repo be security scanned on push?
No
true
boolean
tag
A string containing the Helm chart tag to push (default = latest)
No
latest
string
workspace-root
Workspace root path that is either an absolute path or a path relative to the working directory. Defaults to '.' (the working directory)
No
.
string

push-helm-chart

Push a helm chart to the Amazon ECR registry

Show command Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
account-url
Env var storing Amazon ECR account URL that maps to an AWS account, e.g. {awsAccountNum}.dkr.ecr.us-west-2.amazonaws.com defaults to AWS_ECR_ACCOUNT_URL
No
AWS_ECR_ACCOUNT_URL
env_var_name
helm-version
Helm version to install, .e.g. v3.2.4.
No
v3.2.4
string
path
Path to the directory containing your Helm chart and build context. Defaults to . (working directory).
No
.
string
repo
Name of an Amazon ECR repository
Yes
-
string
tag
A string containing the Helm chart tag to push (default = latest)
No
latest
string

push-image

Push a container image to the Amazon ECR registry

Show command Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
account-url
Env var storing Amazon ECR account URL that maps to an AWS account, e.g. {awsAccountNum}.dkr.ecr.us-west-2.amazonaws.com defaults to AWS_ECR_ACCOUNT_URL
No
AWS_ECR_ACCOUNT_URL
env_var_name
repo
Name of an Amazon ECR repository
Yes
-
string
tag
A comma-separated string containing docker image tags (default = latest)
No
latest
string

Executors

default

CircleCI's Ubuntu-based machine executor VM: https://circleci.com/docs/2.0/executor-types/#using-machine

Show executor Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
image
-
No
ubuntu-2004:202010-01
string
use-docker-layer-caching
-
No
false
boolean

Orb Source

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 # This code is licensed from CircleCI to the user under the MIT license. # See here for details: https://circleci.com/developer/orbs/licensing commands: build-and-push-image: description: | Install AWS CLI, if needed, and configure. Log into Amazon ECR and push image to repository. Requires environment variables for AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. We recommend these be saved in a Project (https://circleci.com/docs/2.0/env-vars/#setting-an-environment-variable-in-a-project) or in Contexts (https://circleci.com/docs/2.0/contexts). parameters: account-url: default: AWS_ECR_ACCOUNT_URL description: | Env var storing Amazon ECR account URL that maps to an AWS account, e.g. {awsAccountNum}.dkr.ecr.us-west-2.amazonaws.com defaults to AWS_ECR_ACCOUNT_URL type: env_var_name attach-workspace: default: false description: | Boolean for whether or not to attach to an existing workspace. Default is false. type: boolean aws-access-key-id: default: AWS_ACCESS_KEY_ID description: | AWS access key id for IAM role. Set this to the name of the environment variable you will set to hold this value, i.e. AWS_ACCESS_KEY. type: env_var_name aws-secret-access-key: default: AWS_SECRET_ACCESS_KEY description: | AWS secret key for IAM role. Set this to the name of the environment variable you will set to hold this value, i.e. AWS_SECRET_ACCESS_KEY. type: env_var_name checkout: default: true description: | Boolean for whether or not to checkout as a first step. Default is true. type: boolean create-repo: default: false description: Should the repo be created if it does not exist? type: boolean docker-login: default: false description: | Enable dockerhub authentication. Defaults to false. type: boolean dockerfile: default: Dockerfile description: Name of dockerfile to use. Defaults to Dockerfile. type: string dockerhub-password: default: DOCKERHUB_PASSWORD description: | Dockerhub password to be configured. Set this to the name of the environment variable you will set to hold this value, i.e. DOCKERHUB_PASSWORD. type: env_var_name dockerhub-username: default: DOCKERHUB_USERNAME description: | Dockerhub username to be configured. Set this to the name of the environment variable you will set to hold this value, i.e. DOCKERHUB_USERNAME. type: env_var_name executor: default: default description: executor to use for this job type: executor extra-build-args: default: "" description: | Extra flags to pass to docker build. For examples, see https://docs.docker.com/engine/reference/commandline/build type: string no-output-timeout: default: 10m description: | The amount of time to allow the docker build command to run before timing out (default is `10m`) type: string path: default: . description: Path to the directory containing your Dockerfile and build context. Defaults to . (working directory). type: string profile-name: default: default description: AWS profile name to be configured. type: string region: default: AWS_REGION description: | Name of env var storing your AWS region information, defaults to AWS_REGION type: env_var_name remote-docker-layer-caching: default: false description: | Enable Docker layer caching if using remote Docker engine. Defaults to false. type: boolean remote-docker-version: default: 19.03.13 description: Specific remote docker version type: string repo: description: Name of an Amazon ECR repository type: string repo-scan-on-push: default: true description: Should the created repo be security scanned on push? type: boolean setup-remote-docker: default: false description: | Setup and use CircleCI's remote Docker environment for Docker and docker-compose commands? Not required if using the default executor type: boolean skip-when-tags-exist: default: false description: Whether to skip image building if all specified tags already exist in ECR type: boolean tag: default: latest description: A comma-separated string containing docker image tags to build and push (default = latest) type: string workspace-root: default: . description: | Workspace root path that is either an absolute path or a path relative to the working directory. Defaults to '.' (the working directory) type: string steps: - when: condition: <<parameters.checkout>> steps: - checkout - when: condition: <<parameters.attach-workspace>> steps: - attach_workspace: at: <<parameters.workspace-root>> - when: condition: <<parameters.setup-remote-docker>> steps: - setup_remote_docker: docker_layer_caching: <<parameters.remote-docker-layer-caching>> version: <<parameters.remote-docker-version>> - docker-ecr-login: account-url: <<parameters.account-url>> aws-access-key-id: <<parameters.aws-access-key-id>> aws-secret-access-key: <<parameters.aws-secret-access-key>> profile-name: <<parameters.profile-name>> region: <<parameters.region>> - when: condition: <<parameters.create-repo>> steps: - run: | aws ecr describe-repositories --profile <<parameters.profile-name>> --region $<<parameters.region>> --repository-names <<parameters.repo>> > /dev/null 2>&1 || \ aws ecr create-repository --profile <<parameters.profile-name>> --region $<<parameters.region>> --repository-name <<parameters.repo>> --image-scanning-configuration scanOnPush=<<parameters.repo-scan-on-push>> - when: condition: <<parameters.docker-login>> steps: - run: | docker login -u $<<parameters.dockerhub-username>> -p $<<parameters.dockerhub-password>> - build-image: account-url: <<parameters.account-url>> aws-access-key-id: <<parameters.aws-access-key-id>> aws-secret-access-key: <<parameters.aws-secret-access-key>> dockerfile: <<parameters.dockerfile>> extra-build-args: <<parameters.extra-build-args>> no-output-timeout: <<parameters.no-output-timeout>> path: <<parameters.path>> profile-name: <<parameters.profile-name>> region: <<parameters.region>> repo: <<parameters.repo>> skip-when-tags-exist: <<parameters.skip-when-tags-exist>> tag: <<parameters.tag>> - push-image: account-url: <<parameters.account-url>> repo: <<parameters.repo>> tag: <<parameters.tag>> build-image: description: Build a docker image parameters: account-url: default: AWS_ECR_ACCOUNT_URL description: | The Amazon ECR account URL that maps to an AWS account, e.g. {awsAccountNum}.dkr.ecr.us-west-2.amazonaws.com type: env_var_name aws-access-key-id: default: AWS_ACCESS_KEY_ID description: | AWS access key id for IAM role. Set this to the name of the environment variable you will set to hold this value, i.e. AWS_ACCESS_KEY. type: env_var_name aws-secret-access-key: default: AWS_SECRET_ACCESS_KEY description: | AWS secret key for IAM role. Set this to the name of the environment variable you will set to hold this value, i.e. AWS_SECRET_ACCESS_KEY. type: env_var_name checkout: default: false description: | Boolean for whether or not to checkout as a first step. Default is false. type: boolean dockerfile: default: Dockerfile description: Name of dockerfile to use. Defaults to Dockerfile. type: string ecr-login: default: false description: | Boolean for whether or not to log in to ECR before building. Default is false. type: boolean extra-build-args: default: "" description: | Extra flags to pass to docker build. For examples, see https://docs.docker.com/engine/reference/commandline/build type: string no-output-timeout: default: 10m description: The amount of time to allow the docker command to run before timing out. type: string path: default: . description: Path to the directory containing your Dockerfile and build context. Defaults to . (working directory). type: string profile-name: default: default description: | AWS profile name to be configured. Only required when skip-when-tags-exist or ecr-login are set to true. type: string region: default: AWS_REGION description: | Name of env var storing your AWS region information, defaults to AWS_REGION. Only required when skip-when-tags-exist or ecr-login are set to true. type: env_var_name repo: description: Name of an Amazon ECR repository type: string skip-when-tags-exist: default: false description: Whether to skip image building if all specified tags already exist in ECR type: boolean tag: default: latest description: A comma-separated string containing docker image tags (default = latest) type: string steps: - when: condition: <<parameters.checkout>> steps: - checkout - when: condition: or: - <<parameters.ecr-login>> - <<parameters.skip-when-tags-exist>> steps: - docker-ecr-login: account-url: <<parameters.account-url>> aws-access-key-id: <<parameters.aws-access-key-id>> aws-secret-access-key: <<parameters.aws-secret-access-key>> profile-name: <<parameters.profile-name>> region: <<parameters.region>> - run: command: | registry_id=$(echo $<<parameters.account-url>> | sed "s;\..*;;g") number_of_tags_in_ecr=0 docker_tag_args="" IFS="," read -ra DOCKER_TAGS \<<< "<< parameters.tag >>" for tag in "${DOCKER_TAGS[@]}"; do if [ "<<parameters.skip-when-tags-exist>>" = "true" ]; then docker_tag_exists_in_ecr=$(aws ecr describe-images --profile <<parameters.profile-name>> --registry-id $registry_id --repository-name <<parameters.repo>> --query "contains(imageDetails[].imageTags[], '$tag')") if [ "$docker_tag_exists_in_ecr" = "true" ]; then docker pull $<<parameters.account-url>>/<<parameters.repo>>:${tag} let "number_of_tags_in_ecr+=1" fi fi docker_tag_args="$docker_tag_args -t $<<parameters.account-url>>/<<parameters.repo>>:$tag" done if [ "<<parameters.skip-when-tags-exist>>" = "false" ] || [ "<<parameters.skip-when-tags-exist>>" = "true" -a $number_of_tags_in_ecr -lt ${#DOCKER_TAGS[@]} ]; then docker build \ <<#parameters.extra-build-args>><<parameters.extra-build-args>><</parameters.extra-build-args>> \ -f <<parameters.path>>/<<parameters.dockerfile>> \ $docker_tag_args \ <<parameters.path>> fi name: Build docker image no_output_timeout: <<parameters.no-output-timeout>> docker-ecr-login: description: Authenticate docker into the Amazon ECR service parameters: account-url: default: AWS_ECR_ACCOUNT_URL description: | Env var storing Amazon ECR account URL that maps to an AWS account, e.g. {awsAccountNum}.dkr.ecr.us-west-2.amazonaws.com defaults to AWS_ECR_ACCOUNT_URL type: env_var_name aws-access-key-id: default: AWS_ACCESS_KEY_ID description: | AWS access key id for IAM role. Set this to the name of the environment variable you will set to hold this value, i.e. AWS_ACCESS_KEY. type: env_var_name aws-secret-access-key: default: AWS_SECRET_ACCESS_KEY description: | AWS secret key for IAM role. Set this to the name of the environment variable you will set to hold this value, i.e. AWS_SECRET_ACCESS_KEY. type: env_var_name profile-name: default: default description: | AWS profile name to be configured. defaults to "default" type: string region: default: AWS_REGION description: | Name of env var storing your AWS region information, defaults to AWS_REGION type: env_var_name steps: - aws-cli/setup: aws-access-key-id: <<parameters.aws-access-key-id>> aws-region: <<parameters.region>> aws-secret-access-key: <<parameters.aws-secret-access-key>> profile-name: <<parameters.profile-name>> - run: command: | # get-login-password returns a password that we pipe to the docker login command aws ecr get-login-password --region $<<parameters.region>> --profile <<parameters.profile-name>> | docker login --username AWS --password-stdin $<<parameters.account-url>> name: Log docker into Amazon ECR helm-ecr-login: description: Authenticate helm into the Amazon ECR service parameters: account-url: default: AWS_ECR_ACCOUNT_URL description: | Env var storing Amazon ECR account URL that maps to an AWS account, e.g. {awsAccountNum}.dkr.ecr.us-west-2.amazonaws.com defaults to AWS_ECR_ACCOUNT_URL type: env_var_name aws-access-key-id: default: AWS_ACCESS_KEY_ID description: | AWS access key id for IAM role. Set this to the name of the environment variable you will set to hold this value, i.e. AWS_ACCESS_KEY. type: env_var_name aws-secret-access-key: default: AWS_SECRET_ACCESS_KEY description: | AWS secret key for IAM role. Set this to the name of the environment variable you will set to hold this value, i.e. AWS_SECRET_ACCESS_KEY. type: env_var_name helm-version: default: v3.2.4 description: | Helm version to install, .e.g. v3.2.4. type: string profile-name: default: default description: | AWS profile name to be configured. defaults to "default" type: string region: default: AWS_REGION description: | Name of env var storing your AWS region information, defaults to AWS_REGION type: env_var_name steps: - aws-cli/setup: aws-access-key-id: <<parameters.aws-access-key-id>> aws-region: <<parameters.region>> aws-secret-access-key: <<parameters.aws-secret-access-key>> profile-name: <<parameters.profile-name>> - helm/install-helm-client: version: <<parameters.helm-version>> - run: command: | export HELM_EXPERIMENTAL_OCI=1 # get-login-password returns a password that we pipe to the helm login command aws ecr get-login-password --region $<<parameters.region>> --profile <<parameters.profile-name>> | \ helm registry login \ --username AWS --password-stdin $<<parameters.account-url>> name: Log helm into Amazon ECR login-and-push-helm-chart: description: | Install AWS CLI and Helm, if needed, and configure. Log into Amazon ECR and push Helm chart to repository. Requires environment variables for AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. We recommend these be saved in a Project (https://circleci.com/docs/2.0/env-vars/#setting-an-environment-variable-in-a-project) or in Contexts (https://circleci.com/docs/2.0/contexts). parameters: account-url: default: AWS_ECR_ACCOUNT_URL description: | Env var storing Amazon ECR account URL that maps to an AWS account, e.g. {awsAccountNum}.dkr.ecr.us-west-2.amazonaws.com defaults to AWS_ECR_ACCOUNT_URL type: env_var_name attach-workspace: default: false description: | Boolean for whether or not to attach to an existing workspace. Default is false. type: boolean aws-access-key-id: default: AWS_ACCESS_KEY_ID description: | AWS access key id for IAM role. Set this to the name of the environment variable you will set to hold this value, i.e. AWS_ACCESS_KEY. type: env_var_name aws-secret-access-key: default: AWS_SECRET_ACCESS_KEY description: | AWS secret key for IAM role. Set this to the name of the environment variable you will set to hold this value, i.e. AWS_SECRET_ACCESS_KEY. type: env_var_name checkout: default: true description: | Boolean for whether or not to checkout as a first step. Default is true. type: boolean create-repo: default: false description: Should the repo be created if it does not exist? type: boolean executor: default: default description: executor to use for this job type: executor path: default: . description: Path to the directory containing your Helm chart and build context. Defaults to . (working directory). type: string profile-name: default: default description: AWS profile name to be configured. type: string region: default: AWS_REGION description: | Name of env var storing your AWS region information, defaults to AWS_REGION type: env_var_name repo: description: Name of an Amazon ECR repository type: string repo-scan-on-push: default: true description: Should the created repo be security scanned on push? type: boolean tag: default: latest description: A string containing the Helm chart tag to push (default = latest) type: string workspace-root: default: . description: | Workspace root path that is either an absolute path or a path relative to the working directory. Defaults to '.' (the working directory) type: string steps: - when: condition: <<parameters.checkout>> steps: - checkout - when: condition: <<parameters.attach-workspace>> steps: - attach_workspace: at: <<parameters.workspace-root>> - helm-ecr-login: account-url: <<parameters.account-url>> aws-access-key-id: <<parameters.aws-access-key-id>> aws-secret-access-key: <<parameters.aws-secret-access-key>> profile-name: <<parameters.profile-name>> region: <<parameters.region>> - when: condition: <<parameters.create-repo>> steps: - run: | aws ecr describe-repositories --profile <<parameters.profile-name>> --region $<<parameters.region>> --repository-names <<parameters.repo>> > /dev/null 2>&1 || \ aws ecr create-repository --profile <<parameters.profile-name>> --region $<<parameters.region>> --repository-name <<parameters.repo>> --image-scanning-configuration scanOnPush=<<parameters.repo-scan-on-push>> - push-helm-chart: account-url: <<parameters.account-url>> path: <<parameters.path>> repo: <<parameters.repo>> tag: <<parameters.tag>> push-helm-chart: description: Push a helm chart to the Amazon ECR registry parameters: account-url: default: AWS_ECR_ACCOUNT_URL description: | Env var storing Amazon ECR account URL that maps to an AWS account, e.g. {awsAccountNum}.dkr.ecr.us-west-2.amazonaws.com defaults to AWS_ECR_ACCOUNT_URL type: env_var_name helm-version: default: v3.2.4 description: Helm version to install, .e.g. v3.2.4. type: string path: default: . description: Path to the directory containing your Helm chart and build context. Defaults to . (working directory). type: string repo: description: Name of an Amazon ECR repository type: string tag: default: latest description: A string containing the Helm chart tag to push (default = latest) type: string steps: - helm/install-helm-client: version: <<parameters.helm-version>> - run: command: | export HELM_EXPERIMENTAL_OCI=1 helm chart save <<parameters.path>> $<<parameters.account-url>>/<<parameters.repo>>:<<parameters.tag>> helm chart push $<<parameters.account-url>>/<<parameters.repo>>:<<parameters.tag>> name: Push chart to Amazon ECR push-image: description: Push a container image to the Amazon ECR registry parameters: account-url: default: AWS_ECR_ACCOUNT_URL description: | Env var storing Amazon ECR account URL that maps to an AWS account, e.g. {awsAccountNum}.dkr.ecr.us-west-2.amazonaws.com defaults to AWS_ECR_ACCOUNT_URL type: env_var_name repo: description: Name of an Amazon ECR repository type: string tag: default: latest description: A comma-separated string containing docker image tags (default = latest) type: string steps: - run: command: | IFS="," read -ra DOCKER_TAGS \<<< "<< parameters.tag >>" for tag in "${DOCKER_TAGS[@]}"; do docker push $<<parameters.account-url>>/<<parameters.repo>>:${tag} done name: Push image to Amazon ECR description: | Build images and push them to the Amazon Elastic Container Registry. display: source_url: https://github.com/CircleCI-Public/aws-ecr-orb examples: simple-build-and-push: description: Log into AWS, build and push image to Amazon ECR usage: orbs: aws-ecr: circleci/aws-ecr@x.y.z version: 2.1 workflows: build_and_push_image: jobs: - aws-ecr/build-and-push-image: account-url: AWS_ECR_ACCOUNT_URL_ENV_VAR_NAME aws-access-key-id: ACCESS_KEY_ID_ENV_VAR_NAME aws-secret-access-key: SECRET_ACCESS_KEY_ENV_VAR_NAME context: myContext create-repo: true dockerfile: myDockerfile no-output-timeout: 20m path: pathToMyDockerfile profile-name: myProfileName region: AWS_REGION_ENV_VAR_NAME repo: myECRRepository skip-when-tags-exist: false tag: latest,myECRRepoTag simple-push-helm-chart: description: Log into AWS and push Helm Chart to Amazon ECR usage: orbs: aws-ecr: circleci/aws-ecr@x.y.z version: 2.1 workflows: build_and_push_image: jobs: - aws-ecr/build-and-push-image: account-url: AWS_ECR_ACCOUNT_URL_ENV_VAR_NAME aws-access-key-id: ACCESS_KEY_ID_ENV_VAR_NAME aws-secret-access-key: SECRET_ACCESS_KEY_ENV_VAR_NAME context: myContext create-repo: true path: pathToMyHelmChart profile-name: myProfileName region: AWS_REGION_ENV_VAR_NAME repo: myECRRepository tag: 1.0.0 executors: default: description: | CircleCI's Ubuntu-based machine executor VM: https://circleci.com/docs/2.0/executor-types/#using-machine machine: docker_layer_caching: <<parameters.use-docker-layer-caching>> image: <<parameters.image>> parameters: image: default: ubuntu-2004:202010-01 type: string use-docker-layer-caching: default: false type: boolean jobs: build-and-push-image: description: | Install AWS CLI, if needed, and configure. Log into Amazon ECR and push image to repository. Requires environment variables for AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. We recommend these be saved in a Project (https://circleci.com/docs/2.0/env-vars/#setting-an-environment-variable-in-a-project) or in Contexts (https://circleci.com/docs/2.0/contexts). executor: <<parameters.executor>> parameters: account-url: default: AWS_ECR_ACCOUNT_URL description: | Env var storing Amazon ECR account URL that maps to an AWS account, e.g. {awsAccountNum}.dkr.ecr.us-west-2.amazonaws.com defaults to AWS_ECR_ACCOUNT_URL type: env_var_name attach-workspace: default: false description: | Boolean for whether or not to attach to an existing workspace. Default is false. type: boolean aws-access-key-id: default: AWS_ACCESS_KEY_ID description: | AWS access key id for IAM role. Set this to the name of the environment variable you will set to hold this value, i.e. AWS_ACCESS_KEY_ID. type: env_var_name aws-secret-access-key: default: AWS_SECRET_ACCESS_KEY description: | AWS secret key for IAM role. Set this to the name of the environment variable you will set to hold this value, i.e. AWS_SECRET_ACCESS_KEY. type: env_var_name checkout: default: true description: | Boolean for whether or not to checkout as a first step. Default is true. type: boolean create-repo: default: false description: Should the repo be created if it does not exist? type: boolean docker-login: default: false description: | Enable dockerhub authentication. Defaults to false. type: boolean dockerfile: default: Dockerfile description: Name of dockerfile to use. Defaults to Dockerfile. type: string dockerhub-password: default: DOCKERHUB_PASSWORD description: | Dockerhub password to be configured. Set this to the name of the environment variable you will set to hold this value, i.e. DOCKERHUB_PASSWORD. type: env_var_name dockerhub-username: default: DOCKERHUB_USERNAME description: | Dockerhub username to be configured. Set this to the name of the environment variable you will set to hold this value, i.e. DOCKERHUB_USERNAME. type: env_var_name executor: default: default description: executor to use for this job type: executor extra-build-args: default: "" description: | Extra flags to pass to docker build. For examples, see https://docs.docker.com/engine/reference/commandline/build type: string no-output-timeout: default: 10m description: | The amount of time to allow the docker build command to run before timing out. Defaults to '10m' type: string path: default: . description: Path to the directory containing your Dockerfile and build context. Defaults to . (working directory). type: string profile-name: default: default description: AWS profile name to be configured. type: string region: default: AWS_REGION description: | Name of env var storing your AWS region information, defaults to AWS_REGION type: env_var_name remote-docker-layer-caching: default: false description: | Enable Docker layer caching if using remote Docker engine. Defaults to false. type: boolean remote-docker-version: default: 19.03.13 description: Specific remote docker version type: string repo: description: Name of an Amazon ECR repository type: string setup-remote-docker: default: false description: | Setup and use CircleCI's remote Docker environment for Docker and docker-compose commands? Not required if using the default executor type: boolean skip-when-tags-exist: default: false description: Whether to skip image building if all specified tags already exist in ECR type: boolean tag: default: latest description: A comma-separated string containing docker image tags to build and push (default = latest) type: string workspace-root: default: . description: | Workspace root path that is either an absolute path or a path relative to the working directory. Defaults to '.' (the working directory) type: string steps: - build-and-push-image: account-url: <<parameters.account-url>> attach-workspace: <<parameters.attach-workspace>> aws-access-key-id: <<parameters.aws-access-key-id>> aws-secret-access-key: <<parameters.aws-secret-access-key>> checkout: <<parameters.checkout>> create-repo: <<parameters.create-repo>> docker-login: <<parameters.docker-login>> dockerfile: <<parameters.dockerfile>> dockerhub-password: <<parameters.dockerhub-password>> dockerhub-username: <<parameters.dockerhub-username>> extra-build-args: <<parameters.extra-build-args>> no-output-timeout: <<parameters.no-output-timeout>> path: <<parameters.path>> profile-name: <<parameters.profile-name>> region: <<parameters.region>> remote-docker-layer-caching: <<parameters.remote-docker-layer-caching>> remote-docker-version: <<parameters.remote-docker-version>> repo: <<parameters.repo>> setup-remote-docker: <<parameters.setup-remote-docker>> skip-when-tags-exist: <<parameters.skip-when-tags-exist>> tag: <<parameters.tag>> workspace-root: <<parameters.workspace-root>> push-helm-chart: description: | Install AWS CLI and Helm, if needed, and configure. Log into Amazon ECR and push helm chart to repository. Requires environment variables for AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. We recommend these be saved in a Project (https://circleci.com/docs/2.0/env-vars/#setting-an-environment-variable-in-a-project) or in Contexts (https://circleci.com/docs/2.0/contexts). executor: <<parameters.executor>> parameters: account-url: default: AWS_ECR_ACCOUNT_URL description: | Env var storing Amazon ECR account URL that maps to an AWS account, e.g. {awsAccountNum}.dkr.ecr.us-west-2.amazonaws.com defaults to AWS_ECR_ACCOUNT_URL type: env_var_name attach-workspace: default: false description: | Boolean for whether or not to attach to an existing workspace. Default is false. type: boolean aws-access-key-id: default: AWS_ACCESS_KEY_ID description: | AWS access key id for IAM role. Set this to the name of the environment variable you will set to hold this value, i.e. AWS_ACCESS_KEY_ID. type: env_var_name aws-secret-access-key: default: AWS_SECRET_ACCESS_KEY description: | AWS secret key for IAM role. Set this to the name of the environment variable you will set to hold this value, i.e. AWS_SECRET_ACCESS_KEY. type: env_var_name checkout: default: true description: | Boolean for whether or not to checkout as a first step. Default is true. type: boolean create-repo: default: false description: Should the repo be created if it does not exist? type: boolean executor: default: default description: executor to use for this job type: executor path: default: . description: Path to the directory containing your Chart and build context. Defaults to . (working directory). type: string profile-name: default: default description: AWS profile name to be configured. type: string region: default: AWS_REGION description: | Name of env var storing your AWS region information, defaults to AWS_REGION type: env_var_name repo: description: Name of an Amazon ECR repository type: string tag: default: latest description: A string containing helm chart tag to push (default = latest) type: string workspace-root: default: . description: | Workspace root path that is either an absolute path or a path relative to the working directory. Defaults to '.' (the working directory) type: string steps: - login-and-push-helm-chart: account-url: <<parameters.account-url>> attach-workspace: <<parameters.attach-workspace>> aws-access-key-id: <<parameters.aws-access-key-id>> aws-secret-access-key: <<parameters.aws-secret-access-key>> checkout: <<parameters.checkout>> create-repo: <<parameters.create-repo>> path: <<parameters.path>> profile-name: <<parameters.profile-name>> region: <<parameters.region>> repo: <<parameters.repo>> tag: <<parameters.tag>> workspace-root: <<parameters.workspace-root>> orbs: aws-cli: circleci/aws-cli@2.0.0 helm: circleci/helm@1.2.0 version: 2.1
Developer Updates
Get tips to optimize your builds
Or join our research panel and give feedback
By submitting this form, you are agreeing to ourTerms of UseandPrivacy Policy.