Credentials Management
When creating a credential in env zero, it can be assigned to one of two scopes:Organization or Project.
- Organization Scope: When a credential is created via the organization credentials page (Organization Settings > Credentials), it is assigned to the
Organizationscope. This makes it available to all projects within the organization. - Project Scope: When a credential is created via the project credentials page (Project Settings > Credentials), it is assigned to the
Projectscope. This makes it available to that specific project and any of its sub-projects.
MANAGE_CREDENTIALS permission at that scope level (organization or project). By default, both Project Admin and Organization Admin roles include this permission.For example, to create or edit credentials in the project “My Project,” you need the
MANAGE_CREDENTIALS permission for that project.
Use case example
A common reason to scope credentials is to separate access between environments. For instance, if you have distinct development and production projects, you can ensure that users in the development project do not have access to production credentials.Amazon Web Services (AWS)
env zero offers three ways for you to connect to your AWS account:- Using AWS Assume Role
- Using IAM user credentials
- Using OIDC
Using AWS Assume Role
This role will be assumed by env zero during a deployment.It will require all permissions required including
GetAccessKeyInfo.
Create an AWS IAM Role
- Click on Roles, then click on Create Role
- Under type of trusted entity, select AWS Account
- Under An AWS account ID, select ‘An AWS account’ and enter
913128560467.
If you have a self-hosted agent installation you should enter the AWS account ID where the agent is installed - Select Require External ID
- Enter an External ID. The value must be equal to your Organization ID
- Click Next:Permissions
- Select AdministratorAccess or whatever policies are required by your IaC
- Click Next:Review
- Enter a name for the role, and click Create Role
- Click on the role you just created. We will need the
Role ARNin subsequent steps
Assume Role DurationTo edit the duration of the Assume Role, go to the Created Role screen and locate Maximum Session Duration. Click Edit and select your relevant duration.
Add your Role ARN and External ID configuration to env zero (via CloudFormation)
You can use the following CloudFormation Template or Terraform HCL to create the AssumeRoleRoleArn will be available in the Outputs tab of your CloudFormation stack.
For security reasons, the ExternalID is resolved on the backend to be your organization ID.
Add your Role ARN configuration to env0 (via Manual Configuration)
- Go to the Settings page, and pick the Credentials tab
- Under Cloud Credentials section, click + Add Credential

Cloud Credentials
- Enter a name for the new credential
- Under Type, pick AWS Assumed Role
- Under Role ARN, enter your role ARN
- Note that your External ID is pre-filled with your env0 Organization ID
- Choose the duration for the deployment’s assumed role (make sure it is equal or less than the duration you set in AWS)
- Click Add
- Go to the project for which you’d like to use this role, then click Project Settings and click Credentials
- Pick the credential you would like to use in this project, this project, then click Add


Picking AWS credential for the project
Change Assumed Role per EnvironmentIf you’d like to override the project’s Assumed Role and use a different Assumed Role for a specific environment, set the following environment variables:
- A variable called
ENV0_AWS_ROLE_ARN- set its value to be the role ARN - A variable called
ENV0_AWS_ROLE_EXTERNAL_ID- its value to your Org ID
ENV0_AWS_ROLE_DURATION, and set its value to the desired duration in seconds. AWS uses a default value of 3600s (1 hour), while env zero uses a default value of 18000s (5 hours).Using AWS user credentials
Create IAM Role & Permissions
- To connect your AWS account, you will need to create an IAM user with programmatic access. See this guide on how to do that. Make sure you save your Access Key ID and Secret Access Key.
- You will need to grant this user the appropriate permissions in order to deploy the resources defined in your IaC code.
Add Your Credentials to env zero
- Go to Settings and click the Credentials tab
- Under Cloud Credentials, click + Add Credential

Cloud Credentials
- Enter a name for the new credential
- Under Type, pick AWS Access Keys
- Under Access Key ID, enter your Access Key ID
- Under Secret Access Key, enter the value of your Secret Access Key
- Click Add

AWS Access Keys
- Go to the project for which you’d like to use this role, then go to Project Settings and click Credentials
- Pick the credential you would like to use in this project, and then click on Save

Picking AWS credential for the project
Google Cloud (GCP)
Create a Service Account
In order to connect your GCS account, you will need to create a Service Account Key. See this guide on how to create one. Make sure to save the JSON key contents.Add Your Credentials to env zero
- Go to the Settings page and click the Credentials tab
- Under Cloud Credentials, click + Add Credential

Cloud Credentials
- Enter a name for the new credential.
- Under Type, pick Google Cloud Service Account
- Under Project ID, enter your GCP project name (optional)
- Under Secret Account Key, copy and paste the JSON key contents directly into the value of this variable
- Click Add

Google Cloud Service Account
- Go to the project for which you’d like to use this role, and then go to Project Settings and click Credentials
- Pick the credential you would like to use in this project, then click Save

Picking GCP credential for a project
Using OIDC with GCP
See instructions here.Azure
Create a Service Principal
In order to access resources a Service Principal needs to be created in your Tenant.This is easiest to do via the AZ CLI.
-
First, make sure you are logged in:
Follow the instructions to login
-
Once logged in, your subscriptions will be returned:
-
Next, set your active subscription:
-
Create a Service Principal for env zero to deploy your terraform stack:
This will return the metadata for your Service Principal:
Add Your Credentials to env zero
- Go to the Settings page, and click on the Credentials tab
- Under the Cloud Credentials section, click + Add Credential

Cloud Credentials
- Enter a name for the new credential
- Under Type, pick Azure Service Principal
- Under Client ID, enter your service principal app ID
- Under Client Secret, enter your service principal password
- Under Subscription ID, enter your subscription ID
- Under Tenant ID, enter your service principal tenant ID
- Click Add

Azure Service Principal
- Select the project for which you’d like to use this role, then go to Project Settings and click Credentials
- Pick the credential you would like to use in this project, then click Save

Picking Azure credential for project
Change Credentials per EnvironmentIf you’d like to override the project’s Credentials and use a different Credentials for a specific environment, set the following environment variables:
- A variable called
ARM_TENANT_ID- set its value to be the “service principal tenant ID” - A variable called
ARM_SUBSCRIPTION_ID- set its value to be the “subscription ID” - A variable called
ARM_CLIENT_SECRET- set its value to be the “service principal password” - A variable called
ARM_CLIENT_ID- set its value to be the “service principal app ID”
Using OIDC with Azure
See instructions here.Oracle Cloud Infrastructure (OCI)
Create an OCI API Key
To create a personal API Key in OCI:- Login to OCI
- Click on your profile pic, and go to User Settings
- Under the Resources section, click on API Keys, and the Add API Key
- When you create an API Key, you will be prompted to download a Private RSA Key. Download it and save it for later, you’re going to need it
- Finally, click Save
- After you create the API key, you’ll be prompted with a Configuration file preview. Save it as well
Add Your Credentials to env zero
- Go to the Settings page and click the Credentials tab
- Under Cloud Credentials, click + Add Credential

- Enter a name for the new credential
- Under Type, pick OCI API Key
- Under Tenancy OCID, copy the tenancy from the configuration file preview
- Under User OCID, copy the user from the configuration file preview
- Under OCI Region, pick the region that matches the one in the configuration file preview
- Under API Key Fingerprint, copy the fingerprint from the configuration file preview
- Under API Key Private Key, copy the private RSA key you downloaded
Other Cloud Providers
If you are using Terraform to manage infrastructure in a different provider than the ones mentioned above, you will need to check the provider’s documentation to understand what authentication options are supported. Generally, you should be able to use specific environment variables for authorization. Same as all the above options, you’ll be able to separate your credentials into projects/environments as you see fit.Customizing Cloud Authentication per Environment
Generally, Cloud Credentials are defined per env zero project. These are translated into environment variables at runtime (like AWS_ACCESS_KEY_ID and AWS_ACCESS_SECRET_KEY for AWS). If you’d like to give different credentials to a specific environment, you could simply override the desired environment variables during deployment.Kubernetes
env zero applies your IaC to create resources in your own Kubernetes cluster. Here you will learn how to give env zero the required permissions to do just that. We support major cloud provider managed clusters, as well as a generalkubeconfig file.
Set Up Kubernetes Credential
Navigate into Organization Settings and click CredentialsUnder Deployment Credentials, click + Add Credential

Kubeconfig
If you want to allow connection to your custom cluster, you can do so by setting up akubeconfig credential in env zero’s UI.
Select the Kubernetes Kubeconfig File credential from the Type dropdown menu and paste your validkubeconfig file.

ConstraintsYour
kubeconfig hould contain exactly one cluster, context and user. The current-context field must be provided, and match the given context.
AWS EKS
Select the Kubernetes - AWS EKS Configuration credential from the Type dropdown menu, then enter your cluster name and region.

CredentialsIn order to access your cluster, you’ll also need to set valid AWS credentials.
GCP GKE
Select the Kubernetes - GCP GKE Configuration credential from the Type dropdown menu and enter your cluster name and region.

CredentialsIn order to access your cluster, you’ll also need to set valid GCP credentials.
Azure AKS
Select the Kubernetes - Azure AKS Configuration credential from the Type dropdown menu and enter your cluster name and resource group.

CredentialsIn order to access your cluster, you’ll also need to set valid Azure credentials.