|
1 | | -# Orb Template |
2 | | - |
| 1 | +# CircleCi Orbs [sidlinux22/aws-code-deploy](https://circleci.com/developer/orbs/orb/sidlinux22/aws-code-deploy) |
3 | 2 |
|
4 | 3 | [](https://circleci.com/gh/sidlinux22/aws-codeDeploy-orb) [](https://circleci.com/developer/orbs/orb/sidlinux22/aws-codeDeploy-orb) [](https://raw.githubusercontent.com/sidlinux22/aws-codeDeploy-orb/master/LICENSE) [](https://discuss.circleci.com/c/ecosystem/orbs) |
5 | 4 |
|
6 | 5 |
|
| 6 | +This CircleCi Orb is designed to interact with AWS CodeDeploy and retrieve deployment-related information. It has several functions to perform different tasks related to CodeDeploy deployments. |
| 7 | + |
| 8 | +## Script Components |
| 9 | + |
| 10 | +1. Import Statements: |
| 11 | + - The script imports necessary modules such as `os`, `sys`, `boto3`, `time`, `logging`, and `ThreadPoolExecutor` from the `concurrent.futures` module. |
| 12 | + |
| 13 | +2. Logging Configuration: |
| 14 | + - The logging module is configured to log messages with a specific format and level. |
| 15 | + |
| 16 | +3. `fetch_target_deployment` Function: |
| 17 | + - This function fetches information about a target deployment in CodeDeploy. |
| 18 | + - It takes the `application_name`, `deployment_group_name`, and `pre_deploy_id` as input parameters. |
| 19 | + - It uses the `boto3` client for CodeDeploy to retrieve the deployment information. |
| 20 | + - The function waits for the deployment to start and checks for any errors or timeouts. |
| 21 | + - It returns the `deploy_id` and `instance_ids` associated with the deployment. |
| 22 | + |
| 23 | +4. `fetch_target_status` Function: |
| 24 | + - This function retrieves the status of a specific target instance in a CodeDeploy deployment. |
| 25 | + - It takes the `deploy_id` and `target_id` as input parameters. |
| 26 | + - It uses the `boto3` client for CodeDeploy to fetch the target's status. |
| 27 | + - It returns the `target_id` and `status` of the target instance. |
7 | 28 |
|
8 | | -A project template for Orbs. |
| 29 | +5. `fetch_code_deploy_status` Function: |
| 30 | + - This function fetches the status of all target instances in a CodeDeploy deployment. |
| 31 | + - It calls the `fetch_target_deployment` function to get the `deploy_id` and `instance_ids`. |
| 32 | + - It continuously checks the status of each instance in the deployment until completion. |
| 33 | + - It counts the instances in different status categories such as completed, in progress, failed, stopped, pending, ready, and skipped. |
| 34 | + - It checks for various conditions such as completion, failure, timeouts, and returns appropriate exit codes. |
9 | 35 |
|
10 | | -This repository is designed to be automatically ingested and modified by the CircleCI CLI's `orb init` command. |
| 36 | +6. `fetch_deployment_id` Function: |
| 37 | + - This function retrieves the deployment ID for a specified application and deployment group. |
| 38 | + - It takes the `application_name` and `deployment_group_name` as input parameters. |
| 39 | + - It uses the `boto3` client for CodeDeploy to fetch the deployment ID. |
| 40 | + - It prints the deployment ID and logs the information. |
11 | 41 |
|
12 | | -_**Edit this area to include a custom title and description.**_ |
| 42 | +7. Main Execution Block: |
| 43 | + - The script checks the command-line arguments provided and validates them. |
| 44 | + - It determines the appropriate action based on the provided flag (`--get-deployment-status` or `--get-deployment-id`). |
| 45 | + - It retrieves the `application_name` and `deployment_group_name` from the command-line arguments. |
| 46 | + - If the flag is `--get-deployment-status`, it |
| 47 | + |
| 48 | + fetches the `pre_deploy_id` and calls the `fetch_code_deploy_status` function. |
| 49 | + - If the flag is `--get-deployment-id`, it calls the `fetch_deployment_id` function. |
| 50 | + - It handles any errors that occur during execution and logs them. |
| 51 | + - It exits with an appropriate exit code based on the execution result. |
| 52 | + |
| 53 | +This script is designed to be run from the command line and provides two main functionalities: fetching the status of a CodeDeploy deployment and retrieving the deployment ID. It utilizes the `boto3` library to interact with AWS CodeDeploy and requires AWS credentials to be set up properly. |
| 54 | + |
| 55 | +Please note that certain values in the script, such as `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_REGION`, are expected to be provided as environment variables. Additionally, when running the script, specific command-line arguments are required depending on the desired functionality. |
| 56 | + |
| 57 | +For detailed usage instructions, you can refer to the comments in the `__main__` block of the script, which provide usage examples for each flag. |
13 | 58 |
|
14 | 59 | --- |
15 | 60 |
|
16 | 61 | ## Resources |
17 | 62 |
|
18 | | -[CircleCI Orb Registry Page](https://circleci.com/developer/orbs/orb/sidlinux22/aws-codeDeploy-orb) - The official registry page of this orb for all versions, executors, commands, and jobs described. |
19 | | - |
20 | | -[CircleCI Orb Docs](https://circleci.com/docs/orb-intro/#section=configuration) - Docs for using, creating, and publishing CircleCI Orbs. |
| 63 | +- [CircleCI Orb Registry Page](https://circleci.com/developer/orbs/orb/sidlinux22/aws-code-deploy) - The official registry page of this orb for all versions, executors, commands, and jobs described. |
| 64 | +- [CircleCI Orb Docs](https://circleci.com/docs/orb-intro/#section=configuration) - Docs for using, creating, and publishing CircleCI Orbs. |
21 | 65 |
|
22 | 66 | ### How to Contribute |
23 | 67 |
|
24 | | -We welcome [issues](https://github.com/sidlinux22/aws-codeDeploy-orb/issues) to and [pull requests](https://github.com/sidlinux22/aws-codeDeploy-orb/pulls) against this repository! |
| 68 | +We welcome [issues](https://github.com/sidlinux22/aws-codeDeploy-orb/issues) and [pull requests](https://github.com/sidlinux22/aws-codeDeploy-orb/pulls) to this repository! |
25 | 69 |
|
26 | 70 | ### How to Publish An Update |
| 71 | + |
27 | 72 | 1. Merge pull requests with desired changes to the main branch. |
28 | 73 | - For the best experience, squash-and-merge and use [Conventional Commit Messages](https://conventionalcommits.org/). |
29 | 74 | 2. Find the current version of the orb. |
30 | 75 | - You can run `circleci orb info sidlinux22/aws-code-deploy | grep "Latest"` to see the current version. |
31 | | -3. Create a [new Release](https://github.com/sidlinux22/aws-codeDeploy-orb/releases/new) on GitHub. |
32 | | - - Click "Choose a tag" and _create_ a new [semantically versioned](http://semver.org/) tag. (ex: v1.0.0) |
| 76 | +3. Create a [new Release](https://github.com/sidlinux22/aws-code-deploy/releases/new) on GitHub. |
| 77 | + - Click "Choose a tag" and create a new [semantically versioned](http://semver.org/) tag (e.g., v1.0.0). |
33 | 78 | - We will have an opportunity to change this before we publish if needed after the next step. |
34 | | -4. Click _"+ Auto-generate release notes"_. |
35 | | - - This will create a summary of all of the merged pull requests since the previous release. |
36 | | - - If you have used _[Conventional Commit Messages](https://conventionalcommits.org/)_ it will be easy to determine what types of changes were made, allowing you to ensure the correct version tag is being published. |
37 | | -5. Now ensure the version tag selected is semantically accurate based on the changes included. |
38 | | -6. Click _"Publish Release"_. |
39 | | - - This will push a new tag and trigger your publishing pipeline on CircleCI. |
| 79 | +4. Click "+ Auto-generate release notes". |
| 80 | + - This will create a summary of all the merged pull requests since the previous release. |
| 81 | + - If you have used [Conventional Commit Messages](https://conventionalcommits.org/), it will be easy to determine what types of changes were made, allowing you to ensure the correct version tag is being published. |
| 82 | +5. Ensure the selected version tag is semantically accurate based on the included changes. |
| 83 | +6. Click "Publish Release". |
| 84 | + - This will push a new tag and trigger your publishing pipeline on CircleCI. |
0 commit comments