Deploy Aembit CLI with GitLab Jobs
This page describes how to use the Aembit CLI in GitLab Jobs.
The Aembit CLI provides the credentials get command to retrieve credentials from your Aembit Tenant.
It simplifies the process of integrating Aembit Edge with GitLab Jobs by providing a command-line interface that handles
the authentication and credential retrieval process.
Configure an Access Policy
Section titled “Configure an Access Policy”To configure your Aembit Tenant to support GitLab Jobs as a Client Workload:
-
Configure your Client Workload to identify the Aembit CLI runtime environment with one or more of the following Client Workload Identifiers:
-
Configure your Trust Provider type to GitLab Job ID Token to identify and attest the Aembit CLI runtime environment.
Make sure to copy the provided Edge SDK Client ID and any Audience values for configuration of the Aembit CLI parameters.
-
Configure your Credential Provider to specify the credential values which you want to be available in the CI runtime environment.
You can use any Credential Provider type. Some may require specifying the
--credential-namesparameter when running the Aembit CLI. -
Configure your Server Workload to specify the service endpoint host and port which you want to use in the CI runtime environment.
You can use any Server Workload type. The
--server-workload-hostand--server-workload-portparameters must match the values you specify in the Server Workload configuration. -
Configure your Access Policy and then click Save Policy & Activate.
Configure a custom Resource Set
Section titled “Configure a custom Resource Set”To configure a GitLab Job to work with a custom Resource Set:
-
Open your existing GitLab CI configuration file.
-
Go to your Aembit Tenant, click the Trust Providers link in the left sidebar and locate your GitLab Trust Provider in the custom Resource Set you are working with.
-
In your
gitlab-ci.ymlfile, either:- update the
AEMBIT_CLIENT_IDand add theAEMBIT_RESOURCE_SET_IDenvironment variables if you moving to a custom Resource Set; or - add both
AEMBIT_CLIENT_IDandAEMBIT_RESOURCE_SET_IDenvironment variables if you are just getting started with enabling your workload to use Aembit.
In the following example, see the
AEMBIT_CLIENT_IDandAEMBIT_RESOURCE_SET_IDenvironment variables in thevariablessection.gitlab-ci.yml variables:AEMBIT_CLIENT_ID: aembit:stack:tenant:identity:gitlab_idtoken:uuidAEMBIT_RESOURCE_SET_ID: bd886157-ba1d-54x86-9f26-3095b0515278 - update the
-
Verify these environment variables match the values in your Resource Set and Trust Provider in your Aembit Tenant.
-
Commit your changes to the GitLab CI configuration file,
.gitlab-ci.yml.
Using the Aembit CLI
Section titled “Using the Aembit CLI”Please review the CLI Reference to review use of the CLI. A GitLab Job specific example follows.
Deploy the CI/CD script
Section titled “Deploy the CI/CD script”-
Retrieve the latest Aembit CLI release from the Aembit CLI releases page.
-
Include Aembit CLI within your CI environment. You do this by bundling it within an image or retrieving it dynamically as appropriate for your workload.
-
Configure your CI script to call Aembit CLI with the proper parameters. The following shows an example
gitlab-ci.ymlconfiguration for a GitLab Job:gitlab-ci.yml sample:variables:# Set this to the value of "Edge SDK Client ID" that is provided in the settings of your Trust Provider.AEMBIT_CLIENT_ID: aembit:stack:tenant:identity:gitlab_idtoken:uuid# Add AEMBIT_RESOURCE_SET_ID if using a Custom Resource Set# Example: AEMBIT_RESOURCE_SET_ID: bd886157-ba1d-54x86-9f26-3095b0515278# AEMBIT_RESOURCE_SET_ID: <your_resource_set_id>id_tokens:GITLAB_OIDC_TOKEN:# Set this to the value of "Edge SDK Audience" that is provided in the settings for your Trust Provider.aud: https://tenant.id.stack.aembit.ioscript:# Following are samples for OAuth Client Credentials flow, API Key, and Username/Password Credential Provider Types.# Please update the --server-workload-host and --server-workload-port values to match your target workloads.# Use 'eval' explicitly to run the output, such as 'export TOKEN=abc123', as shell commands.- eval $(./aembit credentials get --id-token $GITLAB_OIDC_TOKEN --server-workload-host oauth.sample.com --server-workload-port 443)- echo "OAuth Token: $TOKEN"- eval $(./aembit credentials get --id-token $GITLAB_OIDC_TOKEN --server-workload-host apikey.sample.com --server-workload-port 443 --credential-names APIKEY)- echo "API Key Example: $APIKEY"- eval $(./aembit credentials get --id-token $GITLAB_OIDC_TOKEN --server-workload-host password.sample.com --server-workload-port 443 --credential-names USERNAME,PASSWORD)- echo "Username Password Example: $USERNAME -- $PASSWORD"
Verify Aembit CLI
Section titled “Verify Aembit CLI”See Aembit CLI releases for the current version, download links, and verification steps.