├── .circleci ├── config.yml └── test-deploy.yml ├── .github ├── .gitignore ├── CODEOWNERS ├── ISSUE_TEMPLATE │ ├── bug-report-.md │ └── feature-request-.md └── PULL_REQUEST_TEMPLATE │ └── PULL_REQUEST_TEMPLATE.md ├── .yamllint ├── LICENSE ├── README.md ├── sample_app ├── LICENSE.txt ├── appspec.yml ├── index.html └── scripts │ ├── install_dependencies │ ├── start_server │ └── stop_server └── src ├── @orb.yml ├── commands ├── create_application.yml ├── create_deployment_group.yml ├── deploy_bundle.yml └── push_bundle.yml ├── examples ├── deploy_application.yml └── deploy_application_with_oidc.yml ├── executors └── default.yml ├── jobs └── deploy.yml └── scripts ├── create_application.sh ├── create_deployment_group.sh ├── deploy_bundle.sh └── push_bundle.sh /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | setup: true 3 | orbs: 4 | orb-tools: circleci/orb-tools@12.0 5 | shellcheck: circleci/shellcheck@3.1 6 | 7 | filters: &filters 8 | tags: 9 | only: /.*/ 10 | 11 | workflows: 12 | lint-pack: 13 | jobs: 14 | - orb-tools/lint: 15 | filters: *filters 16 | - orb-tools/pack: 17 | filters: *filters 18 | - orb-tools/review: 19 | filters: *filters 20 | - shellcheck/check: 21 | filters: *filters 22 | - orb-tools/continue: 23 | orb_name: aws-code-deploy 24 | pipeline_number: << pipeline.number >> 25 | vcs_type: << pipeline.project.type >> 26 | requires: [orb-tools/lint, orb-tools/review, orb-tools/pack, shellcheck/check] 27 | filters: *filters 28 | -------------------------------------------------------------------------------- /.circleci/test-deploy.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | orbs: 3 | orb-tools: circleci/orb-tools@12.0 4 | aws-cli: circleci/aws-cli@4.0 5 | aws-code-deploy: {} 6 | filters: &filters 7 | tags: 8 | only: /.*/ 9 | release-filters: &release-filters 10 | branches: 11 | ignore: /.*/ 12 | tags: 13 | only: /^v[0-9]+\.[0-9]+\.[0-9]+$/ 14 | jobs: 15 | integration-test: 16 | docker: 17 | - image: cimg/aws:2023.03 18 | steps: 19 | - checkout 20 | - aws-cli/setup: 21 | role_arn: "arn:aws:iam::122211685980:role/CPE_CODE_DEPLOY_OIDC_TEST" 22 | profile_name: OIDC-User 23 | - run: 24 | name: Start Instance 25 | command: aws ec2 start-instances --instance-ids "$AWS_CD_EC2_ID" --region "us-west-1" --profile "OIDC-User" 26 | - aws-code-deploy/push_bundle: 27 | region: "us-west-1" 28 | application_name: CodeDeployOrb_App 29 | bundle_source: ./sample_app 30 | bundle_bucket: aws-codedeploy-orb-test 31 | bundle_key: SampleApp_Linux 32 | profile_name: OIDC-User 33 | - aws-code-deploy/deploy_bundle: 34 | region: "us-west-1" 35 | application_name: CodeDeployOrb_App 36 | deployment_group: CodeDeployOrb_App_Group 37 | bundle_bucket: aws-codedeploy-orb-test 38 | bundle_key: SampleApp_Linux 39 | profile_name: OIDC-User 40 | workflows: 41 | test-deploy: 42 | jobs: 43 | - integration-test: 44 | context: CPE-OIDC 45 | filters: *filters 46 | - aws-code-deploy/deploy: 47 | auth: 48 | - aws-cli/setup: 49 | role_arn: arn:aws:iam::122211685980:role/CPE_CODE_DEPLOY_OIDC_TEST 50 | role_session_name: "Test-session" 51 | profile_name: "OIDC-User" 52 | region: "us-west-1" 53 | profile_name: OIDC-User 54 | application_name: CodeDeployOrb_App 55 | deployment_group: CodeDeployOrb_App_Group 56 | service_role_arn: arn:aws:iam::122211685980:role/CodeDeployServiceRole 57 | bundle_source: ./sample_app 58 | bundle_bucket: aws-codedeploy-orb-test 59 | bundle_key: SampleApp_Linux 60 | context: CPE-OIDC 61 | post-steps: 62 | - run: aws ec2 stop-instances --instance-ids "$AWS_CD_EC2_ID" --region "us-west-1" --profile "OIDC-User" 63 | requires: 64 | - integration-test 65 | - orb-tools/pack: 66 | filters: *release-filters 67 | - orb-tools/publish: 68 | orb_name: circleci/aws-code-deploy 69 | vcs_type: << pipeline.project.type >> 70 | pub_type: production 71 | enable_pr_comment: true 72 | requires: [ orb-tools/pack, integration-test, aws-code-deploy/deploy ] 73 | context: orb-publisher 74 | filters: *release-filters -------------------------------------------------------------------------------- /.github/.gitignore: -------------------------------------------------------------------------------- 1 | orb.yml 2 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Ping these folks when changes are made to this repository 2 | * @CircleCI-Public/orb-publishers 3 | 4 | # We can also add orb-specifc codeowners at some point if desirable 5 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report-.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report! 3 | about: File a bug report to let us know what's wrong! 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Orb Version** 11 | The version number of the orb 12 | 13 | 20 | 21 | **Describe the bug** 22 | 26 | 27 | **To Reproduce** 28 | 29 | 36 | 37 | **Expected behavior** 38 | 39 | 42 | 43 | **Additional context** 44 | 45 | 48 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature-request-.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request! 3 | about: Want something new to be incorporated into this orb? 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Pull Request 3 | about: Default pull request template. 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | ### Checklist 11 | 12 | 17 | 18 | - [ ] All new jobs, commands, executors, parameters have descriptions 19 | - [ ] Examples have been added for any significant new features 20 | - [ ] README has been updated, if necessary 21 | 22 | ### Motivation, Related Issues 23 | 24 | 29 | 30 | ### Description 31 | 32 | 36 | -------------------------------------------------------------------------------- /.yamllint: -------------------------------------------------------------------------------- 1 | extends: relaxed 2 | 3 | rules: 4 | line-length: 5 | max: 200 6 | allow-non-breakable-inline-mappings: true 7 | 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Circle Internet Services, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # aws-code-deploy Orb [![CircleCI Build Status](https://circleci.com/gh/CircleCI-Public/aws-code-deploy-orb.svg?style=shield "CircleCI Build Status")](https://circleci.com/gh/CircleCI-Public/aws-code-deploy) [![CircleCI Orb Version](https://badges.circleci.com/orbs/circleci/aws-code-deploy.svg)](https://circleci.com/orbs/registry/orb/circleci/aws-code-deploy) [![GitHub License](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/CircleCI-Public/aws-code-deploy-orb/master/LICENSE) [![CircleCI Community](https://img.shields.io/badge/community-CircleCI%20Discuss-343434.svg)](https://discuss.circleci.com/c/ecosystem/orbs) 2 | 3 | A CircleCI Orb to easily deploy applications to AWS CodeDeploy. 4 | 5 | ## Resources 6 | 7 | [CircleCI Orb Registry Page](https://circleci.com/orbs/registry/orb/circleci/aws-code-deploy) - The official registry page of this orb for all versions, executors, commands, and jobs described. 8 | [CircleCI Orb Docs](https://circleci.com/docs/2.0/orb-intro/#section=configuration) - Docs for using and creating CircleCI Orbs. 9 | [AWS CodeDeploy](https://aws.amazon.com/codedeploy/) - Automate code deployments to maintain application uptime. 10 | [AWS CodeDeploy Docs](https://docs.aws.amazon.com/codedeploy/latest/userguide/welcome.html) - User Guide 11 | 12 | ### Examples 13 | 14 | Please visit the [orb registry page](https://circleci.com/orbs/registry/orb/circleci/aws-code-deploy#usage-examples) for usage examples and guidelines. 15 | ### How To Contribute 16 | 17 | We welcome [issues](https://github.com/CircleCI-Public/aws-code-deploy-orb/issues) to and [pull requests](https://github.com/CircleCI-Public/aws-code-deploy-orb/pulls) against this repository! 18 | 19 | For further questions/comments about this or other orbs, visit the Orb Category of [CircleCI Discuss](https://discuss.circleci.com/c/orbs). 20 | -------------------------------------------------------------------------------- /sample_app/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2012-2014 Amazon.com, Inc. or its affiliates. All Rights Reserved. 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /sample_app/appspec.yml: -------------------------------------------------------------------------------- 1 | version: 0.0 2 | os: linux 3 | files: 4 | - source: /index.html 5 | destination: /var/www/html/ 6 | hooks: 7 | BeforeInstall: 8 | - location: scripts/install_dependencies 9 | timeout: 300 10 | runas: root 11 | - location: scripts/start_server 12 | timeout: 300 13 | runas: root 14 | ApplicationStop: 15 | - location: scripts/stop_server 16 | timeout: 300 17 | runas: root 18 | -------------------------------------------------------------------------------- /sample_app/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Sample Deployment 6 | 26 | 27 | 28 |
29 |

Congratulations

30 |

This application was deployed using AWS CodeDeploy.

31 |

For next steps, read the AWS CodeDeploy Documentation.

32 |
33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /sample_app/scripts/install_dependencies: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | yum install -y httpd 3 | 4 | -------------------------------------------------------------------------------- /sample_app/scripts/start_server: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | service httpd start 3 | 4 | -------------------------------------------------------------------------------- /sample_app/scripts/stop_server: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | isExistApp = `pgrep httpd` 3 | if [[ -n $isExistApp ]]; then 4 | service httpd stop 5 | fi 6 | 7 | -------------------------------------------------------------------------------- /src/@orb.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | 3 | description: > 4 | Easily deploy applications to AWS CodeDeploy on CircleCI with the aws-code-deploy orb 5 | 6 | display: 7 | home_url: "https://aws.amazon.com/codedeploy/" 8 | source_url: "https://github.com/CircleCI-Public/aws-code-deploy-orb" 9 | -------------------------------------------------------------------------------- /src/commands/create_application.yml: -------------------------------------------------------------------------------- 1 | description: > 2 | Creates an application. 3 | parameters: 4 | application_name: 5 | description: 6 | "The name of an AWS CodeDeploy application associated with the applicable IAM user or AWS account." 7 | type: string 8 | arguments: 9 | description: If you wish to pass any additional arguments to the aws deploy command 10 | type: string 11 | default: '' 12 | profile_name: 13 | description: 14 | "The name of an AWS profile to use with aws-cli commands" 15 | type: string 16 | default: 'default' 17 | region: 18 | type: string 19 | default: ${AWS_DEFAULT_REGION} 20 | description: > 21 | AWS region of CodeDeploy App. Defaults to environment variable ${AWS_DEFAULT_REGION}. 22 | steps: 23 | - run: 24 | name: ensure-application-created 25 | environment: 26 | ORB_STR_APPLICATION_NAME: << parameters.application_name >> 27 | ORB_STR_ARGUMENTS: << parameters.arguments >> 28 | ORB_STR_PROFILE_NAME: << parameters.profile_name >> 29 | ORB_STR_REGION: << parameters.region >> 30 | command: << include(scripts/create_application.sh) >> 31 | -------------------------------------------------------------------------------- /src/commands/create_deployment_group.yml: -------------------------------------------------------------------------------- 1 | description: | 2 | Creates a deployment group to which application revisions are deployed. 3 | parameters: 4 | application_name: 5 | description: 6 | "The name of an AWS CodeDeploy application associated with the applicable IAM user or AWS account." 7 | type: string 8 | deployment_group: 9 | description: 10 | "The name of a new deployment group for the specified application." 11 | type: string 12 | deployment_config: 13 | description: 14 | "Predefined deployment configuration name." 15 | type: enum 16 | enum: [ CodeDeployDefault.OneAtATime, CodeDeployDefault.HalfAtATime, CodeDeployDefault.AllAtOnce ] 17 | default: "CodeDeployDefault.OneAtATime" 18 | service_role_arn: 19 | description: 20 | "The service role for a deployment group." 21 | type: string 22 | arguments: 23 | description: If you wish to pass any additional arguments to the create_deployment_group command 24 | type: string 25 | default: '' 26 | get_deployment_group_arguments: 27 | description: If you wish to pass any additional arguments to the get-deployment-group command 28 | type: string 29 | default: '' 30 | profile_name: 31 | description: 32 | "The name of an AWS profile to use with aws-cli commands" 33 | type: string 34 | default: 'default' 35 | region: 36 | type: string 37 | default: ${AWS_DEFAULT_REGION} 38 | description: > 39 | AWS region of CodeDeploy App. Defaults to environment variable ${AWS_DEFAULT_REGION}. 40 | steps: 41 | - run: 42 | name: ensure-deployment-created 43 | environment: 44 | ORB_STR_APPLICATION_NAME: << parameters.application_name >> 45 | ORB_STR_DEPLOYMENT_GROUP: << parameters.deployment_group >> 46 | ORB_STR_DEPLOYMENT_CONFIG: << parameters.deployment_config >> 47 | ORB_STR_SERVICE_ROLE_ARN: << parameters.service_role_arn >> 48 | ORB_STR_ARGUMENTS: << parameters.arguments >> 49 | ORB_STR_GET_DEPLOYMENT_GROUP_ARGUMENTS: << parameters.get_deployment_group_arguments>> 50 | ORB_STR_PROFILE_NAME: << parameters.profile_name >> 51 | ORB_STR_REGION: << parameters.region >> 52 | command: << include(scripts/create_deployment_group.sh) >> 53 | -------------------------------------------------------------------------------- /src/commands/deploy_bundle.yml: -------------------------------------------------------------------------------- 1 | description: | 2 | Deploy from a bundle and wait until the deployment has successfully completed. 3 | parameters: 4 | application_name: 5 | description: 6 | "The name of an AWS CodeDeploy application associated with the applicable IAM user or AWS account." 7 | type: string 8 | deployment_group: 9 | description: 10 | "The name of a new deployment group for the specified application." 11 | type: string 12 | deployment_config: 13 | description: 14 | "Predefined deployment configuration name." 15 | type: enum 16 | enum: [ CodeDeployDefault.OneAtATime, CodeDeployDefault.HalfAtATime, CodeDeployDefault.AllAtOnce ] 17 | default: "CodeDeployDefault.OneAtATime" 18 | bundle_bucket: 19 | description: 20 | "The s3 bucket where an application revision will be stored" 21 | type: string 22 | bundle_key: 23 | description: 24 | "A key under the s3 bucket where an application revision will be stored" 25 | type: string 26 | bundle_type: 27 | description: 28 | "The file type used for an application revision bundle. Currently defaults to 'zip'" 29 | type: string 30 | default: "zip" 31 | get_deployment_group_arguments: 32 | description: If you wish to pass any additional arguments to the get-deployment-group command 33 | type: string 34 | default: '' 35 | deploy_bundle_arguments: 36 | description: 37 | "If you wish to pass any additional arguments to the aws create-deployment command" 38 | type: string 39 | default: '' 40 | profile_name: 41 | description: 42 | "The name of an AWS profile to use with aws-cli commands" 43 | type: string 44 | default: 'default' 45 | region: 46 | type: string 47 | default: ${AWS_DEFAULT_REGION} 48 | description: > 49 | AWS region of CodeDeploy App. Defaults to environment variable ${AWS_DEFAULT_REGION}. 50 | steps: 51 | - run: 52 | name: deploy_bundle 53 | environment: 54 | ORB_STR_APPLICATION_NAME: << parameters.application_name >> 55 | ORB_STR_DEPLOYMENT_GROUP: << parameters.deployment_group >> 56 | ORB_STR_DEPLOYMENT_CONFIG: << parameters.deployment_config >> 57 | ORB_STR_BUNDLE_BUCKET: << parameters.bundle_bucket >> 58 | ORB_STR_BUNDLE_KEY: << parameters.bundle_key >> 59 | ORB_STR_BUNDLE_TYPE: << parameters.bundle_type >> 60 | ORB_STR_GET_DEPLOYMENT_GROUP_ARGUMENTS: << parameters.get_deployment_group_arguments >> 61 | ORB_STR_DEPLOY_BUNDLE_ARGUMENTS: << parameters.deploy_bundle_arguments >> 62 | ORB_STR_PROFILE_NAME: << parameters.profile_name >> 63 | ORB_STR_REGION: << parameters.region >> 64 | command: << include(scripts/deploy_bundle.sh) >> 65 | -------------------------------------------------------------------------------- /src/commands/push_bundle.yml: -------------------------------------------------------------------------------- 1 | description: | 2 | Bundles and uploads to Amazon Simple Storage Service (Amazon S3) an application revision 3 | parameters: 4 | application_name: 5 | description: 6 | "The name of an AWS CodeDeploy application associated with the applicable IAM user or AWS account." 7 | type: string 8 | bundle_source: 9 | description: 10 | "The directory relative to your project to package up into an application revision." 11 | type: string 12 | default: "." 13 | bundle_bucket: 14 | description: 15 | "The s3 bucket where an application revision will be stored" 16 | type: string 17 | bundle_key: 18 | description: 19 | "A key under the s3 bucket where an application revision will be stored" 20 | type: string 21 | bundle_type: 22 | description: 23 | "The file type used for an application revision bundle. Currently defaults to 'zip'" 24 | type: string 25 | default: "zip" 26 | arguments: 27 | description: If you wish to pass any additional arguments to the aws deploy command 28 | type: string 29 | default: '' 30 | profile_name: 31 | description: 32 | "The name of an AWS profile to use with aws-cli commands" 33 | type: string 34 | default: 'default' 35 | region: 36 | type: string 37 | default: ${AWS_DEFAULT_REGION} 38 | description: > 39 | AWS region of CodeDeploy App. Defaults to environment variable ${AWS_DEFAULT_REGION}. 40 | steps: 41 | - run: 42 | name: push_bundle 43 | environment: 44 | ORB_STR_APPLICATION_NAME: << parameters.application_name >> 45 | ORB_EVAL_BUNDLE_SOURCE: << parameters.bundle_source >> 46 | ORB_STR_BUNDLE_BUCKET: << parameters.bundle_bucket >> 47 | ORB_STR_BUNDLE_KEY: << parameters.bundle_key >> 48 | ORB_STR_BUNDLE_TYPE: << parameters.bundle_type >> 49 | ORB_STR_ARGUMENTS: << parameters.arguments >> 50 | ORB_STR_PROFILE_NAME: << parameters.profile_name >> 51 | ORB_STR_REGION: << parameters.region >> 52 | command: << include(scripts/push_bundle.sh) >> 53 | -------------------------------------------------------------------------------- /src/examples/deploy_application.yml: -------------------------------------------------------------------------------- 1 | description: > 2 | Deploy an application to AWS CodeDeploy using static AWS keys for authentication. 3 | Import the aws-cli orb and authenticate using the aws-cli/setup command with static AWS keys stored as env_vars (AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY). 4 | usage: 5 | version: 2.1 6 | orbs: 7 | aws-code-deploy: circleci/aws-code-deploy@4.0 8 | # Importing aws-cli orb is required for authentication 9 | aws-cli: circleci/aws-cli@4.0 10 | 11 | workflows: 12 | deploy_application: 13 | jobs: 14 | - aws-code-deploy/deploy: 15 | auth: 16 | # Configure aws credentials with static keys stored as env_vars (AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY) 17 | - aws-cli/setup 18 | application_name: myApplication 19 | deployment_group: myDeploymentGroup 20 | service_role_arn: myDeploymentGroupRoleARN 21 | bundle_bucket: myApplicationS3Bucket 22 | bundle_key: myS3BucketKey 23 | -------------------------------------------------------------------------------- /src/examples/deploy_application_with_oidc.yml: -------------------------------------------------------------------------------- 1 | description: > 2 | Deploy an application to AWS CodeDeploy using OIDC authentication. 3 | Import the aws-cli orb and authenticate using the aws-cli/setup command with a valid role-arn for OIDC authentication. 4 | usage: 5 | version: 2.1 6 | orbs: 7 | aws-code-deploy: circleci/aws-code-deploy@4.0 8 | # Importing aws-cli orb is required for OIDC authentication 9 | aws-cli: circleci/aws-cli@4.0 10 | 11 | workflows: 12 | deploy_application: 13 | jobs: 14 | - aws-code-deploy/deploy: 15 | auth: 16 | # Add authentication step with OIDC using aws-cli/setup command 17 | - aws-cli/setup: 18 | profile: "OIDC-USER" 19 | role-arn: "arn:aws:iam::123456789012:role/VALID_OIDC_CODEDEPLOY_ROLE" 20 | application_name: myApplication 21 | deployment_group: myDeploymentGroup 22 | service_role_arn: myDeploymentGroupRoleARN 23 | bundle_bucket: myApplicationS3Bucket 24 | bundle_key: myS3BucketKey 25 | # Must use same profile configured in aws-cli/setup command 26 | profile: "OIDC-USER" 27 | # must use valid CircleCI context for OIDC authentication 28 | context: CircleCI_OIDC_Token 29 | -------------------------------------------------------------------------------- /src/executors/default.yml: -------------------------------------------------------------------------------- 1 | description: | 2 | An AWS Docker image built to run on CircleCI that contains the AWS CLI and related tools. 3 | parameters: 4 | tag: 5 | description: > 6 | Select any of the available tags here: https://circleci.com/developer/images/image/cimg/aws. 7 | type: string 8 | default: "2023.06" 9 | resource_class: 10 | description: Configure the executor resource class 11 | type: enum 12 | enum: ["small", "medium", "medium+", "large", "xlarge", "2xlarge", "2xlarge+"] 13 | default: "medium" 14 | 15 | docker: 16 | - image: cimg/aws:<> 17 | resource_class: <> 18 | -------------------------------------------------------------------------------- /src/jobs/deploy.yml: -------------------------------------------------------------------------------- 1 | description: > 2 | Ensures an application and deployment group exist then proceeds to 3 | bundle and upload an application revision to S3. Once uploaded this 4 | job will finally create a deployment based on that revision. 5 | parameters: 6 | application_name: 7 | description: 8 | "The name of an AWS CodeDeploy application associated with the applicable IAM user or AWS account." 9 | type: string 10 | deployment_group: 11 | description: 12 | "The name of a new deployment group for the specified application." 13 | type: string 14 | deployment_config: 15 | description: 16 | "Predefined deployment configuration name." 17 | type: enum 18 | enum: [ CodeDeployDefault.OneAtATime, CodeDeployDefault.HalfAtATime, CodeDeployDefault.AllAtOnce ] 19 | default: "CodeDeployDefault.OneAtATime" 20 | service_role_arn: 21 | description: 22 | "The service role for a deployment group." 23 | type: string 24 | bundle_source: 25 | description: 26 | "The directory relative to your project to package up into an application revision." 27 | type: string 28 | default: "." 29 | bundle_bucket: 30 | description: 31 | "The s3 bucket where an application revision will be stored" 32 | type: string 33 | bundle_key: 34 | description: 35 | "A key under the s3 bucket where an application revision will be stored" 36 | type: string 37 | bundle_type: 38 | description: 39 | "The file type used for an application revision bundle. Currently defaults to 'zip'" 40 | type: string 41 | default: "zip" 42 | arguments: 43 | description: If you wish to pass any additional arguments to the aws deploy command 44 | type: string 45 | default: '' 46 | get_deployment_group_arguments: 47 | description: If you wish to pass any additional arguments to the get-deployment-group command 48 | type: string 49 | default: '' 50 | deploy_bundle_arguments: 51 | description: If you wish to pass any additional arguments to the deploy_bundle command 52 | type: string 53 | default: '' 54 | profile_name: 55 | description: 56 | "The name of an AWS profile to use with aws-cli commands" 57 | type: string 58 | default: 'default' 59 | auth: 60 | description: | 61 | The authentication method used to access your AWS account. Import the aws-cli orb in your config and 62 | provide the aws-cli/setup command to authenticate with your preferred method. View examples for more information. 63 | type: steps 64 | region: 65 | type: string 66 | default: ${AWS_DEFAULT_REGION} 67 | description: > 68 | AWS region of CodeDeploy App. Defaults to environment variable ${AWS_DEFAULT_REGION}. 69 | executor: 70 | description: The executor to use for this job. By default, this will use the "default" executor provided by this orb. 71 | type: executor 72 | default: default 73 | executor: << parameters.executor >> 74 | steps: 75 | - checkout 76 | - steps: << parameters.auth >> 77 | - create_application: 78 | application_name: << parameters.application_name >> 79 | arguments: << parameters.arguments >> 80 | profile_name: << parameters.profile_name >> 81 | region: << parameters.region >> 82 | - create_deployment_group: 83 | application_name: << parameters.application_name >> 84 | deployment_group: << parameters.deployment_group >> 85 | deployment_config: << parameters.deployment_config >> 86 | service_role_arn: << parameters.service_role_arn >> 87 | get_deployment_group_arguments: << parameters.get_deployment_group_arguments >> 88 | arguments: << parameters.arguments >> 89 | profile_name: << parameters.profile_name >> 90 | region: << parameters.region >> 91 | - push_bundle: 92 | application_name: << parameters.application_name >> 93 | bundle_source: << parameters.bundle_source >> 94 | bundle_bucket: << parameters.bundle_bucket >> 95 | bundle_key: << parameters.bundle_key >> 96 | bundle_type: << parameters.bundle_type >> 97 | arguments: << parameters.arguments >> 98 | profile_name: << parameters.profile_name >> 99 | region: << parameters.region >> 100 | - deploy_bundle: 101 | application_name: << parameters.application_name >> 102 | deployment_group: << parameters.deployment_group >> 103 | deployment_config: << parameters.deployment_config >> 104 | bundle_bucket: << parameters.bundle_bucket >> 105 | bundle_key: << parameters.bundle_key >> 106 | bundle_type: << parameters.bundle_type >> 107 | get_deployment_group_arguments: << parameters.get_deployment_group_arguments >> 108 | deploy_bundle_arguments: << parameters.deploy_bundle_arguments >> 109 | profile_name: << parameters.profile_name >> 110 | region: << parameters.region >> 111 | -------------------------------------------------------------------------------- /src/scripts/create_application.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ORB_STR_APPLICATION_NAME="$(circleci env subst "${ORB_STR_APPLICATION_NAME}")" 3 | ORB_STR_REGION="$(circleci env subst "${ORB_STR_REGION}")" 4 | ORB_STR_PROFILE_NAME="$(circleci env subst "${ORB_STR_PROFILE_NAME}")" 5 | ORB_STR_ARGUMENTS="$(circleci env subst "${ORB_STR_ARGUMENTS}")" 6 | 7 | set +e 8 | aws deploy get-application \ 9 | --application-name "${ORB_STR_APPLICATION_NAME}" --profile "${ORB_STR_PROFILE_NAME}" --region "${ORB_STR_REGION}" \ 10 | "${ORB_STR_ARGUMENTS}" 11 | if $? -ne 0; then 12 | set -e 13 | echo "No application named ${ORB_STR_APPLICATION_NAME} found. Trying to create a new one" 14 | else 15 | set -e 16 | echo "Application named ${ORB_STR_APPLICATION_NAME} already exists. Skipping creation." 17 | fi 18 | -------------------------------------------------------------------------------- /src/scripts/create_deployment_group.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ORB_STR_APPLICATION_NAME="$(circleci env subst "${ORB_STR_APPLICATION_NAME}")" 3 | ORB_STR_DEPLOYMENT_GROUP="$(circleci env subst "${ORB_STR_DEPLOYMENT_GROUP}")" 4 | ORB_STR_REGION="$(circleci env subst "${ORB_STR_REGION}")" 5 | ORB_STR_ARGUMENTS="$(circleci env subst "${ORB_STR_ARGUMENTS}")" 6 | ORB_STR_PROFILE_NAME="$(circleci env subst "${ORB_STR_PROFILE_NAME}")" 7 | ORB_STR_SERVICE_ROLE_ARN="$(circleci env subst "${ORB_STR_SERVICE_ROLE_ARN}")" 8 | 9 | set +e 10 | aws deploy get-deployment-group \ 11 | --application-name "${ORB_STR_APPLICATION_NAME}" \ 12 | --deployment-group-name "${ORB_STR_DEPLOYMENT_GROUP}" \ 13 | --region "${ORB_STR_REGION}" \ 14 | --profile "${ORB_STR_PROFILE_NAME}" "${ORB_STR_GET_DEPLOYMENT_GROUP_ARGUMENTS}" 15 | 16 | if $? -ne 0; then 17 | set -e 18 | echo "No deployment group named ${ORB_STR_DEPLOYMENT_GROUP} found. Trying to create a new one" 19 | aws deploy create-deployment-group \ 20 | --application-name "${ORB_STR_APPLICATION_NAME}" \ 21 | --deployment-group-name "${ORB_STR_DEPLOYMENT_GROUP}" \ 22 | --deployment-config-name "${ORB_STR_DEPLOYMENT_CONFIG}" \ 23 | --service-role-arn "${ORB_STR_SERVICE_ROLE_ARN}" "${ORB_STR_ARGUMENTS}" 24 | else 25 | set -e 26 | echo "Deployment group named ${ORB_STR_DEPLOYMENT_GROUP} already exists. Skipping creation." 27 | fi 28 | 29 | -------------------------------------------------------------------------------- /src/scripts/deploy_bundle.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ORB_STR_APPLICATION_NAME="$(circleci env subst "${ORB_STR_APPLICATION_NAME}")" 3 | ORB_STR_DEPLOYMENT_GROUP="$(circleci env subst "${ORB_STR_DEPLOYMENT_GROUP}")" 4 | ORB_STR_BUNDLE_BUCKET="$(circleci env subst "${ORB_STR_BUNDLE_BUCKET}")" 5 | ORB_STR_BUNDLE_KEY="$(circleci env subst "${ORB_STR_BUNDLE_KEY}")" 6 | ORB_STR_REGION="$(circleci env subst "${ORB_STR_REGION}")" 7 | ORB_STR_GET_DEPLOYMENT_GROUP_ARGUMENTS="$(circleci env subst "${ORB_STR_GET_DEPLOYMENT_GROUP_ARGUMENTS}")" 8 | ORB_STR_BUNDLE_TYPE="$(circleci env subst "${ORB_STR_BUNDLE_TYPE}")" 9 | ORB_STR_DEPLOY_BUNDLE_ARGUMENTS="$(circleci env subst "${ORB_STR_DEPLOY_BUNDLE_ARGUMENTS}")" 10 | 11 | if [ -n "${ORB_STR_GET_DEPLOYMENT_GROUP_ARGUMENTS}" ]; then 12 | set -- "$@" "${ORB_STR_GET_DEPLOYMENT_GROUP_ARGUMENTS}" 13 | fi 14 | 15 | if [ -n "${ORB_STR_DEPLOY_BUNDLE_ARGUMENTS}" ]; then 16 | set -- "$@" "${ORB_STR_DEPLOY_BUNDLE_ARGUMENTS}" 17 | fi 18 | 19 | ID=$(aws deploy create-deployment \ 20 | --application-name "${ORB_STR_APPLICATION_NAME}" \ 21 | --deployment-group-name "${ORB_STR_DEPLOYMENT_GROUP}" \ 22 | --deployment-config-name "${ORB_STR_DEPLOYMENT_CONFIG}" \ 23 | --region "${ORB_STR_REGION}" \ 24 | --s3-location bucket="${ORB_STR_BUNDLE_BUCKET}",bundleType="${ORB_STR_BUNDLE_TYPE}",key="${ORB_STR_BUNDLE_KEY}"."${ORB_STR_BUNDLE_TYPE}" \ 25 | --profile "${ORB_STR_PROFILE_NAME}" \ 26 | --output text \ 27 | --query '[deploymentId]' "${ORB_STR_DEPLOY_BUNDLE_ARGUMENTS}") 28 | STATUS=$(aws deploy get-deployment \ 29 | --deployment-id "$ID" \ 30 | --output text \ 31 | --profile "${ORB_STR_PROFILE_NAME}" \ 32 | --region "${ORB_STR_REGION}" \ 33 | --query '[deploymentInfo.status]' \ 34 | "${ORB_STR_GET_DEPLOYMENT_GROUP_ARGUMENTS}") 35 | while [ "$STATUS" = "Created" ] || [ "$STATUS" = "InProgress" ] || [ "$STATUS" = "Pending" ] || [ "$STATUS" = "Queued" ] || [ "$STATUS" = "Ready" ]; do 36 | echo "Status: $STATUS..." 37 | STATUS=$(aws deploy get-deployment \ 38 | --deployment-id "$ID" \ 39 | --profile "${ORB_STR_PROFILE_NAME}" \ 40 | --region "${ORB_STR_REGION}" \ 41 | --output text \ 42 | --query '[deploymentInfo.status]'"${ORB_STR_GET_DEPLOYMENT_GROUP_ARGUMENTS}") 43 | sleep 5 44 | done 45 | if [ "$STATUS" = "Succeeded" ]; then 46 | EXITCODE=0 47 | echo "Deployment finished." 48 | else 49 | EXITCODE=1 50 | echo "Deployment failed!" 51 | fi 52 | aws deploy get-deployment --deployment-id "$ID" \ 53 | "${ORB_STR_GET_DEPLOYMENT_GROUP_ARGUMENTS}" \ 54 | --profile "${ORB_STR_PROFILE_NAME}" \ 55 | --region "${ORB_STR_REGION}" \ 56 | --profile "${ORB_STR_PROFILE_NAME}" 57 | exit $EXITCODE 58 | -------------------------------------------------------------------------------- /src/scripts/push_bundle.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ORB_STR_APPLICATION_NAME="$(circleci env subst "${ORB_STR_APPLICATION_NAME}")" 3 | ORB_STR_BUNDLE_BUCKET="$(circleci env subst "${ORB_STR_BUNDLE_BUCKET}")" 4 | ORB_STR_BUNDLE_KEY="$(circleci env subst "${ORB_STR_BUNDLE_KEY}")" 5 | ORB_STR_REGION="$(circleci env subst "${ORB_STR_REGION}")" 6 | ORB_STR_ARGUMENTS="$(circleci env subst "${ORB_STR_ARGUMENTS}")" 7 | ORB_STR_PROFILE_NAME="$(circleci env subst "${ORB_STR_PROFILE_NAME}")" 8 | ORB_EVAL_BUNDLE_SOURCE="$(eval echo "${ORB_EVAL_BUNDLE_SOURCE}")" 9 | 10 | if [ -n "${ORB_STR_ARGUMENTS}" ]; then 11 | set -- "$@" "${ORB_STR_ARGUMENTS}" 12 | fi 13 | 14 | aws deploy push \ 15 | --application-name "${ORB_STR_APPLICATION_NAME}" \ 16 | --source "${ORB_EVAL_BUNDLE_SOURCE}" \ 17 | --profile "${ORB_STR_PROFILE_NAME}" \ 18 | --region "${ORB_STR_REGION}" \ 19 | --s3-location s3://"${ORB_STR_BUNDLE_BUCKET}/${ORB_STR_BUNDLE_KEY}.${ORB_VAL_BUNDLE_TYPE}" "$@" 20 | --------------------------------------------------------------------------------