US-EPA-CAMD / devops

Common DevOps files & build scripts for CI/CD pipelines
https://epa.gov/airmarkets
MIT License
1 stars 0 forks source link
bash shell

GitHub Account API ZAP Scan Auth API ZAP Scan Emissions API ZAP Scan Facilities API ZAP Scan Master Data API ZAP Scan Monitor Plan API ZAP Scan Quartz API ZAP Scan

Development Operations (DevOps)

This repo stores common shared devops related files used by one or more repos within the US EPA CAMD organization

Cloud Foundry CLI

For the scripts to function properly the Cloud Foundry cli must be installed in order to run cf commands

Environment Variables

On Linux or Debian systems create a bash script in the /etc/profile.d folder with the following environment variables...

export CF_USERNAME=set to cf service account id
export CF_PASSWORD=set to cf service account password

NOTE: On Windows systems just create system level environment variables

Cloud Foundry Login

$ cf api https://api.fr.cloud.gov
$ cf auth
$ cf target -o $CF_ORG_NAME -s $CF_SPACE_NAME

CF SSH Tunnel

This script will login to cloud.gov and establish an SSH tunnel forwarding the remote port back to the local port providing a channel to communicate to cloud.gov services such as a database service. The application specified must be bound to the service prior to establishing the connection.

$ ./cf-ssh-tunnel.sh --organization $CF_ORG_NAME --space $CF_SPACE_NAME --host $CF_DB_HOST --application $CF_APPLICATON --localPort $LOCAL_PORT --remotePort $REMOTE_PORT

NOTE: Replace $PARAMS with actual values or see the Environment Variables section regarding creating environment variables

EXAMPLE

$ ./cf-ssh-tunnel.sh --organization epa-easey --space dev --host cg-aws-broker-prodg1t1yiwikl6s1rs.ci7nkegdizyy.us-gov-west-1.rds.amazonaws.com --application facilities-api --localPort 15210 --remotePort 5432

Bind Service

To bind an application to a service within cloud.gov run the following commands at a cmd prompt that is logged into cloud.gov...

Usage

$ cf bind-service APP_NAME SERVICE_INSTANCE [-c PARAMETERS_AS_JSON] [--binding-name BINDING_NAME]

Optionally provide service-specific configuration parameters in a valid JSON object in-line:

$ cf bind-service APP_NAME SERVICE_INSTANCE -c '{"name":"value","name":"value"}'

Optionally provide a file containing service-specific configuration parameters in a valid JSON object. The path to the parameters file can be an absolute or relative path to a file.

$ cf bind-service APP_NAME SERVICE_INSTANCE -c PATH_TO_FILE

Example of valid JSON object: { "permissions": "read-only" } Optionally provide a binding name for the association between an app and a service instance:

$ cf bind-service APP_NAME SERVICE_INSTANCE --binding-name BINDING_NAME

EXAMPLES

Linux/Mac:

$ cf bind-service myapp mydb -c '{"permissions":"read-only"}'

Windows Command Line:

$ cf bind-service myapp mydb -c "{\"permissions\":\"read-only\"}"

Windows PowerShell:

$ cf bind-service myapp mydb -c '{\"permissions\":\"read-only\"}'`
$ cf bind-service myapp mydb -c ~/workspace/tmp/instance_config.json --binding-name BINDING_NAME

Github Runner Error

The runner is trying to run your file as a script, but it looks like your file is missing the execute bit.

Example Error: /home/runner/work/_temp/62e75df7-5b8e-4d5b-b728-cbac6fff4ad1.sh: line 1: devops/scripts/*.sh: Permission denied Error: Process completed with exit code 126.

On Linux or macOS, run:

$ chmod +x scripts/
$ git add .

On Windows, run:

$ git add --chmod=+x -- scripts/*
$ git add --chmod=+x -- scripts/*.*

And then push the changes back up.

License & Contributing

​ This project is licensed under the MIT License. We encourage you to read this project’s License, Contributing Guidelines, and Code of Conduct.

Disclaimer

The United States Environmental Protection Agency (EPA) GitHub project code is provided on an "as is" basis and the user assumes responsibility for its use. EPA has relinquished control of the information and no longer has responsibility to protect the integrity , confidentiality, or availability of the information. Any reference to specific commercial products, processes, or services by service mark, trademark, manufacturer, or otherwise, does not constitute or imply their endorsement, recommendation or favoring by EPA. The EPA seal and logo shall not be used in any manner to imply endorsement of any commercial product or activity by EPA or the United States Government.