Skip to main content

GCP Cloud Provider for Idem

Project description

Made with pop, a Python implementation of Plugin Oriented Programming Made with idem, a Python implementation of Plugin Oriented Programming Documentation is published with Sphinx on docs.idemproject.io Made with Python

GCP Cloud Provider for Idem.

About

idem-gcp helps manage GCP with idem.

What is POP?

This project is built with pop, a Python-based implementation of Plugin Oriented Programming (POP). POP seeks to bring together concepts and wisdom from the history of computing in new ways to solve modern computing problems.

For more information:

What is Idem?

This project is built with idem, an idempotent, imperatively executed, declarative programming language written in Python. This project extends idem!

For more information:

Getting Started

Prerequisites

  • Python 3.8+

  • git (if installing from source, or contributing to the project)

Installation

If wanting to use idem-gcp, you can do so by either installing from PyPI or from source.

Install from PyPI

pip install idem-gcp

Install from source

Clone the idem_gcp repository.

git clone git@gitlab.com:vmware/idem/idem-gcp.git
cd idem_gcp

Create a virtual environment, and then activate it:

python3 -m venv venv
source venv/bin/activate

Install idem-gcp and other base requirements:

pip3 install -e .
pip3 install -r requirements/base.txt

Install the following packages in order to run the tests:

pip3 install -r requirements/py3.10/tests.txt

NOTE: Change py3.10 if needed with your Python version. There is support for py3.8, py3.9, py3.10 and py3.11.

Setup

After installation GCP Idem Provider execution and state modules will be accessible to the pop hub. In order to use them we need to set up our credentials.

Create a new file called credentials.yaml and populate it with your credential profiles.

To provide your GCP credentials in the file, use the “gcp” provider key. Under that key, add different profiles as needed. A profile specifies authentication parameters for GCP. The default profile will be automatically used by idem, but the other ones could be explicitly specified for each run or SLS file. This is done through the –acct-profile idem cli flag or the acct_profile SLS property.

There is currently one GCP authentication mechanism supported by idem-gcp - providing service account keys. The following example gives the overall structure of the authentication parameters’ expected format.

credentials.yaml

gcp:
  default:
    type: service_account
    project_id: “<project>”
    private_key_id: “<key_id>”
    private_key: "-----BEGIN PRIVATE KEY-----\n<private_key>\n-----END PRIVATE KEY-----\n"
    client_email: “<service_account_email>“
    client_id: “<client_id>”
    auth_uri: https://accounts.google.com/o/oauth2/auth
    token_uri: https://oauth2.googleapis.com/token
    auth_provider_x509_cert_url: https://www.googleapis.com/oauth2/v1/certs
    client_x509_cert_url: “<certificate_url>“
    universe_domain: googleapis.com
  <other_profile_name>:
    ...

The values of these parameters can be obtained through the GCP console after creating a service account and generating a service account key in JSON format. Be sure to assign appropriate roles for the service account, such that it has the rights to access and manage the needed resources. For a better security posture, follow the principal of least privilege and do not use service accounts with excessive rights. For more information on the authentication parameters used, refer to the Credentials docs.

Encrypt the created credentials file:

acct encrypt credentials.yaml

The output of this command is the ACCT_KEY which needs to be securely stored. A credentials.yaml.fernet encrypted file is also created in the working directory, whose path should be used as ACCT_FILE. These could be given to idem either through environment variables or directly as idem run parameters.

Setting environment variables

export ACCT_KEY="<ACCT_KEY>"
export ACCT_FILE=$PWD/credentials.yaml.fernet

Providing acct parameters to the idem run

idem <subcommand> --acct-key "<ACCT_KEY>" --acct-file "$PWD/credentials.yaml.fernet" --acct-profile "<profile_name>"

Specifying account profile in SLS files

ensure_resource:
  gcp.<service>.<resource>.present:
    - acct_profile: <profile_name>
    - name: resource_name
    - kwarg1: val1

For more information on the Idem ACCT authentication management subsystem, refer to the following resources:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

idem_gcp-2.2.2.tar.gz (190.6 kB view details)

Uploaded Source

Built Distribution

idem_gcp-2.2.2-py3-none-any.whl (283.7 kB view details)

Uploaded Python 3

File details

Details for the file idem_gcp-2.2.2.tar.gz.

File metadata

  • Download URL: idem_gcp-2.2.2.tar.gz
  • Upload date:
  • Size: 190.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/41.0 requests/2.31.0 requests-toolbelt/1.0.0 urllib3/2.0.4 tqdm/4.66.1 importlib-metadata/6.8.0 keyring/24.2.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.9.18

File hashes

Hashes for idem_gcp-2.2.2.tar.gz
Algorithm Hash digest
SHA256 55b2e313211c6a76315e995e217f619b71b4ed33ac4fadf5968af89d34badc21
MD5 f362bb8b77b72cc2d02d53cbdf87fb48
BLAKE2b-256 67eac9c3356cdcd67542903152137158df2de7ed6b0db01d265c25065379ab26

See more details on using hashes here.

File details

Details for the file idem_gcp-2.2.2-py3-none-any.whl.

File metadata

  • Download URL: idem_gcp-2.2.2-py3-none-any.whl
  • Upload date:
  • Size: 283.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/41.0 requests/2.31.0 requests-toolbelt/1.0.0 urllib3/2.0.4 tqdm/4.66.1 importlib-metadata/6.8.0 keyring/24.2.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.9.18

File hashes

Hashes for idem_gcp-2.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 af00ce07dd5dd645c42e765c38f783edaf10efab125a0f16eea3d09e5b56adff
MD5 e7aea5760618a4ade99f76fc217f0f77
BLAKE2b-256 8fd99fc4f3386381d8975857916b1b2de212d43cefc0420d7ef56ac6358071f9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page