Skip to content

Commit 51faa3b

Browse files
authored
Merge pull request #2 from sidlinux22/feature/0.0.1
feat: release feature/0.0.1
2 parents 6b63d15 + 37b33a6 commit 51faa3b

File tree

13 files changed

+125
-70
lines changed

13 files changed

+125
-70
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ workflows:
2323
- orb-tools/continue:
2424
pipeline_number: << pipeline.number >>
2525
vcs_type: << pipeline.project.type >>
26-
orb_name: aws-codeDeploy-status
26+
orb_name: aws-code-deploy
2727
requires: [orb-tools/lint, orb-tools/pack, orb-tools/review, shellcheck/check]
2828
filters: *filters

.circleci/test-deploy.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ orbs:
44
# Reference your orb's jobs and commands below as they will exist when built.
55
orb-tools: circleci/[email protected]
66
# The orb definition is intentionally not included here. It will be injected into the pipeline.
7-
aws-codeDeploy-status: {}
7+
aws-code-deploy: sidlinux22/[email protected]
88

99
# Use this tag to ensure test jobs always run,
1010
# even though the downstream publish job will only run on release tags.
@@ -28,7 +28,17 @@ jobs:
2828
steps:
2929
- checkout
3030
# Run your orb's commands to validate them.
31-
- aws-codeDeploy-status/get-deployment-id
31+
- aws-code-deploy/get_deployment_id:
32+
application_name: "change_to_codeDeploy_application_name"
33+
deployment_group_name: "change_to_codeDeploy_deployment_group_name"
34+
# Get the latest deployment ID for the specified application and deployment group
35+
# Add CodeDeploy Steps like copying Artifcate to S3 etc...
36+
# Fetch new CodeDeploy deployment ID status.
37+
- aws-code-deploy/get_deployment_status:
38+
application_name: "change_to_codeDeploy_application_name"
39+
deployment_group_name: "change_to_codeDeploy_deployment_group_name"
40+
deployment_start_timeout: 300
41+
deployment_completion_timeout: 600
3242
workflows:
3343
test-deploy:
3444
jobs:
@@ -40,7 +50,7 @@ workflows:
4050
- orb-tools/pack:
4151
filters: *release-filters
4252
- orb-tools/publish:
43-
orb_name: sidlinux22/aws-codeDeploy-status
53+
orb_name: sidlinux22/aws-code-deploy
4454
vcs_type: << pipeline.project.type >>
4555
pub_type: production
4656
# Ensure this job requires all test jobs and the pack job.

README.md

Lines changed: 62 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,84 @@
1-
# Orb Template
2-
1+
# CircleCi Orbs [sidlinux22/aws-code-deploy](https://circleci.com/developer/orbs/orb/sidlinux22/aws-code-deploy)
32

43
[![CircleCI Build Status](https://circleci.com/gh/sidlinux22/aws-codeDeploy-orb.svg?style=shield "CircleCI Build Status")](https://circleci.com/gh/sidlinux22/aws-codeDeploy-orb) [![CircleCI Orb Version](https://badges.circleci.com/orbs/sidlinux22/aws-codeDeploy-orb.svg)](https://circleci.com/developer/orbs/orb/sidlinux22/aws-codeDeploy-orb) [![GitHub License](https://img.shields.io/badge/license-MIT-lightgrey.svg)](https://raw.githubusercontent.com/sidlinux22/aws-codeDeploy-orb/master/LICENSE) [![CircleCI Community](https://img.shields.io/badge/community-CircleCI%20Discuss-343434.svg)](https://discuss.circleci.com/c/ecosystem/orbs)
54

65

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.
728

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.
935

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.
1141

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.
1358

1459
---
1560

1661
## Resources
1762

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.
2165

2266
### How to Contribute
2367

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!
2569

2670
### How to Publish An Update
71+
2772
1. Merge pull requests with desired changes to the main branch.
2873
- For the best experience, squash-and-merge and use [Conventional Commit Messages](https://conventionalcommits.org/).
2974
2. Find the current version of the orb.
3075
- 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).
3378
- 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.

src/@orb.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
version: 2.1
22

33
description: >
4-
Sample orb description
4+
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.
55
# This information will be displayed in the orb registry and is not mandatory.
66
display:
77
home_url: "https://github.com/sidlinux22/aws-codeDeploy-orb/tree/main#readme"
88
source_url: "https://github.com/sidlinux22/aws-codeDeploy-orb"
99

10-
# If your orb requires other orbs, you can import them like this. Otherwise remove the "orbs" stanza.
11-
# orbs:
12-
# hello: circleci/hello-build@0.0.5
10+
# Orb requires other orbs, you can import them like this.
11+
orbs:
12+
aws-cli: circleci/aws-cli@4.0.0
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
description: >
22
This command is to get CodeDeploy latest deployment.
33
parameters:
4-
application-name:
4+
application_name:
55
type: string
66
description: "The name of the CodeDeploy application."
7-
deployment-group-name:
7+
deployment_group_name:
88
type: string
99
description: "The name of the CodeDeploy deployment group."
1010
steps:
1111
- run:
1212
environment:
13-
APP_NAME: <<parameters.application-name>>
14-
DEPLOY_GROUP_NAME: <<parameters.deployment-group-name>>
15-
name: CodeDeploy - Get the latest Deployment ID for <<parameters.deployment-group-name>>
16-
command: <<include(scripts/get-deployment-id.sh)>>
13+
APP_NAME: <<parameters.application_name>>
14+
DEPLOY_GROUP_NAME: <<parameters.deployment_group_name>>
15+
name: CodeDeploy - Get the latest Deployment ID for <<parameters.deployment_group_name>>
16+
command: <<include(scripts/get_deployment_id.sh)>>
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
description: >
22
This command is to get CodeDeploy latest deployment.
33
parameters:
4-
application-name:
4+
application_name:
55
type: string
66
description: "The name of the CodeDeploy application."
7-
deployment-group-name:
7+
deployment_group_name:
88
type: string
99
description: "The name of the CodeDeploy deployment group."
10-
deployment-start-timeout:
10+
deployment_start_timeout:
1111
type: integer
1212
default: 180
1313
description: "Timeout for deployment start."
14-
deployment-completion-timeout:
14+
deployment_completion_timeout:
1515
type: integer
1616
default: 600
1717
description: "Timeout for deployment completion."
18-
pre-deployment-id:
18+
pre_deployment_id:
1919
default: ''
2020
type: string
2121
description: "Latest previous deployment ID."
2222
steps:
2323
- run:
2424
environment:
25-
APP_NAME: <<parameters.application-name>>
26-
DEPLOY_GROUP_NAME: <<parameters.deployment-group-name>>
27-
DEPLOYMENT_START_TIMEOUT: <<parameters.deployment-start-timeout>>
28-
DEPLOYMENT_COMPLETION_TIMEOUT: <<parameters.deployment-completion-timeout>>
29-
name: CodeDeploy - Fetch <<parameters.deployment-group-name>> deployment status.
30-
command: <<include(scripts/get-deployment-status.sh)>>
25+
APP_NAME: <<parameters.application_name>>
26+
DEPLOY_GROUP_NAME: <<parameters.deployment_group_name>>
27+
DEPLOYMENT_START_TIMEOUT: <<parameters.deployment_start_timeout>>
28+
DEPLOYMENT_COMPLETION_TIMEOUT: <<parameters.deployment_completion_timeout>>
29+
name: CodeDeploy - Fetch <<parameters.deployment_group_name>> deployment status.
30+
command: <<include(scripts/get_deployment_status.sh)>>

src/examples/example.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ usage:
2424
region: AWS_REGION
2525
# Provide AWS access key, secret access key, and region as environment variables
2626
# Fetch latest deployment ID before new deployment start.
27-
- aws-code-deploy/get-deployment-id:
28-
application-name: "change_to_codeDeploy_application-name"
29-
deployment-group-name: "change_to_codeDeploy_deployment-group-name"
27+
- aws-code-deploy/get_deployment_id:
28+
application_name: "change_to_codeDeploy_application_name"
29+
deployment_group_name: "change_to_codeDeploy_deployment_group_name"
3030
# Get the latest deployment ID for the specified application and deployment group
3131
# Add CodeDeploy Steps like copying Artifcate to S3 etc...
3232
# Fetch new CodeDeploy deployment ID status.
33-
- aws-code-deploy/get-deployment-status:
34-
application-name: "change_to_codeDeploy_application-name"
35-
deployment-group-name: "change_to_codeDeploy_deployment-group-name"
36-
deployment-start-timeout: "Optional_change_to_codeDeploy_deployment-start-timeout"
37-
deployment-completion-timeout: "Optional_change_to_codeDeploy_deployment-completion-timeout"
33+
- aws-code-deploy/get_deployment_status:
34+
application_name: "change_to_codeDeploy_application_name"
35+
deployment_group_name: "change_to_codeDeploy_deployment_group_name"
36+
deployment_start_timeout: "Optional_change_to_codeDeploy_deployment_start_timeout"
37+
deployment_completion_timeout: "Optional_change_to_codeDeploy_deployment_completion_timeout"
3838
# Get the status of the new CodeDeploy deployment using the latest deployment ID
3939
workflows:
4040
version: 2
@@ -44,4 +44,4 @@ usage:
4444
filters:
4545
branches:
4646
ignore: /develop|master/
47-
# Specify branch filters for the workflow execution
47+
# Specify branch filters for the workflow execution

src/executors/default.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ parameters:
1414

1515
docker:
1616
- image: cimg/aws:<<parameters.tag>>
17-
resource_class: <<parameters.resource_class>>
17+
resource_class: <<parameters.resource_class>>
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
description: >
22
A job to get CodeDeploy latest deployment.
33
parameters:
4-
application-name:
4+
application_name:
55
type: string
66
default: ''
77
description: "The name of the CodeDeploy application."
8-
deployment-group-name:
8+
deployment_group_name:
99
type: string
1010
default: ''
1111
description: "The name of the CodeDeploy deployment group."
@@ -15,6 +15,6 @@ parameters:
1515
default: default
1616
executor: << parameters.executor >>
1717
steps:
18-
- get-deployment-id:
19-
application-name: << parameters.application-name >>
20-
deployment-group-name: << parameters.deployment-group-name>>
18+
- get_deployment_id:
19+
application_name: << parameters.application_name >>
20+
deployment_group_name: << parameters.deployment_group_name>>
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
description: >
22
A job to get CodeDeploy latest deployment.
33
parameters:
4-
application-name:
4+
application_name:
55
type: string
66
default: ''
77
description: "The name of the CodeDeploy application."
8-
deployment-group-name:
8+
deployment_group_name:
99
type: string
1010
default: ''
1111
description: "The name of the CodeDeploy deployment group."
12-
deployment-start-timeout:
12+
deployment_start_timeout:
1313
type: integer
1414
default: 180
1515
description: "Timeout for deployment start."
16-
deployment-completion-timeout:
16+
deployment_completion_timeout:
1717
type: integer
1818
default: 600
1919
description: "Timeout for deployment completion."
@@ -23,6 +23,6 @@ parameters:
2323
default: default
2424
executor: << parameters.executor >>
2525
steps:
26-
- get-deployment-status:
27-
application-name: << parameters.application-name >>
28-
deployment-group-name: << parameters.deployment-group-name>>
26+
- get_deployment_status:
27+
application_name: << parameters.application_name >>
28+
deployment_group_name: << parameters.deployment_group_name>>

0 commit comments

Comments
 (0)