Skip to content

A simple python module to work with aws opsworks more easily.

License

Notifications You must be signed in to change notification settings

chaturanga50/opsworks-cli

Repository files navigation

opsworks-cli

opsworks-cli

A simple python module to work with aws opsworks.

Build Status Sonarcloud Status SonarCloud Coverage SonarCloud Bugs SonarCloud Vulnerabilities PyPI version License

How to install

You can download the updated release version from pypi repo using pip or directly from our github releases and unzip the content.

pip install opsworks-cli

Configuration

opsworks-cli needs to access the AWS API using your credentials. Just like the AWS SDK or CLI, it will look for credentials in two places:

  • From the shared credentials file (~/.aws/credentials)
  • From environment variables

To use the credentials file, create a ~/.aws/credentials file based on the template below:

[default]
aws_access_key_id=your_access_key
aws_secret_access_key=your_secret_key

Usage

You can see the list of parameters available via opsworks-cli --help

Options:

  • Update custom cookbook - Update all the cookbook cache in the instances in the layer or update all the instances in entire stack.
  • Execute recipes - Execute specific cookbook against layer or stack.
  • Setup - Running setup against layer or stack.
  • Deploy - Deploy application to the layer or stack.

update-custom-cookbook

* region - OpsWorks stack region (required)
* stack - OpsWorks stack ID (required)
* layer - OpsWorks layer ID (optional)
opsworks-cli update-custom-cookbooks --region eu-west-1 \
             --stack 2e7f6dd5-e4a3-4389-bc95-b4bacc234df0 \
             --layer ac0df176-104b-46ae-946e-7cf7367b816e
opsworks-cli update-custom-cookbooks --region eu-west-1 \
             --stack 2e7f6dd5-e4a3-4389-bc95-b4bacc234df0

execute-recipes

* region - OpsWorks stack region (required)
* stack - OpsWorks stack ID (required)
* layer - OpsWorks layer ID (optional)
* cookbook - chef cookbook (required)
* custom-json - custom json file with extra vars (optional)
opsworks-cli execute-recipes --region eu-west-1 \
             --stack 2e7f6dd5-e4a3-4389-bc95-b4bacc234df0 \
             --layer ac0df176-104b-46ae-946e-7cf7367b816e \
             --cookbook apache::default \
             --custom-json [{"lamp":{ "packages": { "app-sso": "17.1.6" } } }]
opsworks-cli execute-recipes --region eu-west-1 \
             --stack 2e7f6dd5-e4a3-4389-bc95-b4bacc234df0 \
             --layer ac0df176-104b-46ae-946e-7cf7367b816e \
             --cookbook apache::default
opsworks-cli execute-recipes --region eu-west-1 \
             --stack 2e7f6dd5-e4a3-4389-bc95-b4bacc234df0 \
             --cookbook apache::default
             --custom-json [{"lamp":{ "packages": { "app-sso": "17.1.6" } } }]
opsworks-cli execute-recipes --region eu-west-1 \
             --stack 2e7f6dd5-e4a3-4389-bc95-b4bacc234df0 \
             --cookbook apache::default

setup

* region - OpsWorks stack region (required)
* stack - OpsWorks stack ID (required)
* layer - OpsWorks layer ID (optional)
opsworks-cli setup --region eu-west-1 \
             --stack 2e7f6dd5-e4a3-4389-bc95-b4bacc234df0 \
             --layer ac0df176-104b-46ae-946e-7cf7367b816e
opsworks-cli setup --region eu-west-1 \
             --stack 2e7f6dd5-e4a3-4389-bc95-b4bacc234df0

deploy

* region - OpsWorks stack region (required)
* stack - OpsWorks stack ID (required)
* layer - OpsWorks layer ID (optional)
* app - OpsWorks application ID (required)
* custom-json - custom json file with extra vars (optional)
opsworks-cli deploy --region eu-west-1 \
             --stack 2e7f6dd5-e4a3-4389-bc95-b4bacc234df0 \
             --layer ac0df176-104b-46ae-946e-7cf7367b816e \
             --app 2da891ea-1809-480d-a799-cb2c08746115 \
             --custom-json [{"lamp":{ "packages": { "app-sso": "17.1.6" } } }]
opsworks-cli deploy --region eu-west-1 \
             --stack 2e7f6dd5-e4a3-4389-bc95-b4bacc234df0 \
             --app 2da891ea-1809-480d-a799-cb2c08746115 \
             --custom-json [{"lamp":{ "packages": { "app-sso": "17.1.6" } } }]
opsworks-cli deploy --region eu-west-1 \
             --stack 2e7f6dd5-e4a3-4389-bc95-b4bacc234df0 \
             --layer ac0df176-104b-46ae-946e-7cf7367b816e \
             --app 2da891ea-1809-480d-a799-cb2c08746115
opsworks-cli deploy --region eu-west-1 \
             --stack 2e7f6dd5-e4a3-4389-bc95-b4bacc234df0 \
             --app 2da891ea-1809-480d-a799-cb2c08746115

How it works

  • sending opsworks commands via aws api to specific stack or layer id.
  • then opsworks-cli is waiting for the response output from aws api.
  • once we got the response from aws api, opsworks-cli will show the final output accordingly.

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Authors

  • Chathuranga Abeyrathna - github

Contributors

License

opsworks-cli is licensed under the Apache 2.0 License