curl --request POST \
--url https://api.env0.com/aws-access-setups \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"organizationId": "<string>",
"deploymentCredentialId": "<string>",
"includeCostData": true,
"deployAccountIds": [
"<string>"
],
"deployRolePolicyArns": [
"<string>"
],
"deployRolePermissionsBoundaryArn": "<string>",
"deployProjectIds": [
"<string>"
],
"deployTrustedPrincipalArn": "<string>",
"organizationUnitIds": [
"<string>"
],
"templateRepository": "<string>",
"templateRevision": "<string>",
"templatePath": "<string>",
"projectName": "<string>",
"environmentName": "<string>"
}
'import requests
url = "https://api.env0.com/aws-access-setups"
payload = {
"organizationId": "<string>",
"deploymentCredentialId": "<string>",
"includeCostData": True,
"deployAccountIds": ["<string>"],
"deployRolePolicyArns": ["<string>"],
"deployRolePermissionsBoundaryArn": "<string>",
"deployProjectIds": ["<string>"],
"deployTrustedPrincipalArn": "<string>",
"organizationUnitIds": ["<string>"],
"templateRepository": "<string>",
"templateRevision": "<string>",
"templatePath": "<string>",
"projectName": "<string>",
"environmentName": "<string>"
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
organizationId: '<string>',
deploymentCredentialId: '<string>',
includeCostData: true,
deployAccountIds: ['<string>'],
deployRolePolicyArns: ['<string>'],
deployRolePermissionsBoundaryArn: '<string>',
deployProjectIds: ['<string>'],
deployTrustedPrincipalArn: '<string>',
organizationUnitIds: ['<string>'],
templateRepository: '<string>',
templateRevision: '<string>',
templatePath: '<string>',
projectName: '<string>',
environmentName: '<string>'
})
};
fetch('https://api.env0.com/aws-access-setups', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.env0.com/aws-access-setups",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'organizationId' => '<string>',
'deploymentCredentialId' => '<string>',
'includeCostData' => true,
'deployAccountIds' => [
'<string>'
],
'deployRolePolicyArns' => [
'<string>'
],
'deployRolePermissionsBoundaryArn' => '<string>',
'deployProjectIds' => [
'<string>'
],
'deployTrustedPrincipalArn' => '<string>',
'organizationUnitIds' => [
'<string>'
],
'templateRepository' => '<string>',
'templateRevision' => '<string>',
'templatePath' => '<string>',
'projectName' => '<string>',
'environmentName' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.env0.com/aws-access-setups"
payload := strings.NewReader("{\n \"organizationId\": \"<string>\",\n \"deploymentCredentialId\": \"<string>\",\n \"includeCostData\": true,\n \"deployAccountIds\": [\n \"<string>\"\n ],\n \"deployRolePolicyArns\": [\n \"<string>\"\n ],\n \"deployRolePermissionsBoundaryArn\": \"<string>\",\n \"deployProjectIds\": [\n \"<string>\"\n ],\n \"deployTrustedPrincipalArn\": \"<string>\",\n \"organizationUnitIds\": [\n \"<string>\"\n ],\n \"templateRepository\": \"<string>\",\n \"templateRevision\": \"<string>\",\n \"templatePath\": \"<string>\",\n \"projectName\": \"<string>\",\n \"environmentName\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.env0.com/aws-access-setups")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"organizationId\": \"<string>\",\n \"deploymentCredentialId\": \"<string>\",\n \"includeCostData\": true,\n \"deployAccountIds\": [\n \"<string>\"\n ],\n \"deployRolePolicyArns\": [\n \"<string>\"\n ],\n \"deployRolePermissionsBoundaryArn\": \"<string>\",\n \"deployProjectIds\": [\n \"<string>\"\n ],\n \"deployTrustedPrincipalArn\": \"<string>\",\n \"organizationUnitIds\": [\n \"<string>\"\n ],\n \"templateRepository\": \"<string>\",\n \"templateRevision\": \"<string>\",\n \"templatePath\": \"<string>\",\n \"projectName\": \"<string>\",\n \"environmentName\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.env0.com/aws-access-setups")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"organizationId\": \"<string>\",\n \"deploymentCredentialId\": \"<string>\",\n \"includeCostData\": true,\n \"deployAccountIds\": [\n \"<string>\"\n ],\n \"deployRolePolicyArns\": [\n \"<string>\"\n ],\n \"deployRolePermissionsBoundaryArn\": \"<string>\",\n \"deployProjectIds\": [\n \"<string>\"\n ],\n \"deployTrustedPrincipalArn\": \"<string>\",\n \"organizationUnitIds\": [\n \"<string>\"\n ],\n \"templateRepository\": \"<string>\",\n \"templateRevision\": \"<string>\",\n \"templatePath\": \"<string>\",\n \"projectName\": \"<string>\",\n \"environmentName\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"setupId": "<string>",
"organizationId": "<string>",
"accountMode": "single",
"includeCostData": true,
"deployAccountIds": [
"<string>"
],
"deploySignInMethod": "oidc",
"draftId": "<string>",
"projectId": "<string>",
"environmentId": "<string>",
"deploymentLogId": "<string>",
"status": "planning",
"deployCredentials": [
{
"awsAccountId": "<string>",
"credentialId": "<string>"
}
],
"deployRolePolicyArns": [
"<string>"
],
"deployRolePermissionsBoundaryArn": "<string>",
"deployProjectIds": [
"<string>"
],
"deployTrustedPrincipalArn": "<string>",
"templateRepository": "<string>",
"templateRevision": "<string>",
"templateRef": "<string>",
"templatePath": "<string>",
"planSummary": {
"added": 123,
"changed": 123,
"destroyed": 123
},
"failure": {
"phase": "plan",
"message": "<string>"
},
"approvalsPending": true,
"readRoleFailures": [
{
"awsAccountId": "<string>",
"status": "<string>",
"detailedStatus": "<string>",
"reason": "<string>"
}
],
"readRoleRepair": true,
"readRolesRepairedAt": "<string>",
"readRolesUnchecked": "self_hosted_agent",
"cloudCompassCredentialId": "<string>"
}Set up AWS access through an env zero environment
Creates a Cloud Compass draft and a setup environment (“env zero aws roles” unless environmentName names it), in the setup project of the given deployment credential (“env zero setup” unless projectName names it), and deploys it with that credential. It deploys env zero’s template, or any public GitHub repository in templateRepository, which must keep the template’s variables and outputs. The plan waits for approval.
curl --request POST \
--url https://api.env0.com/aws-access-setups \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"organizationId": "<string>",
"deploymentCredentialId": "<string>",
"includeCostData": true,
"deployAccountIds": [
"<string>"
],
"deployRolePolicyArns": [
"<string>"
],
"deployRolePermissionsBoundaryArn": "<string>",
"deployProjectIds": [
"<string>"
],
"deployTrustedPrincipalArn": "<string>",
"organizationUnitIds": [
"<string>"
],
"templateRepository": "<string>",
"templateRevision": "<string>",
"templatePath": "<string>",
"projectName": "<string>",
"environmentName": "<string>"
}
'import requests
url = "https://api.env0.com/aws-access-setups"
payload = {
"organizationId": "<string>",
"deploymentCredentialId": "<string>",
"includeCostData": True,
"deployAccountIds": ["<string>"],
"deployRolePolicyArns": ["<string>"],
"deployRolePermissionsBoundaryArn": "<string>",
"deployProjectIds": ["<string>"],
"deployTrustedPrincipalArn": "<string>",
"organizationUnitIds": ["<string>"],
"templateRepository": "<string>",
"templateRevision": "<string>",
"templatePath": "<string>",
"projectName": "<string>",
"environmentName": "<string>"
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
organizationId: '<string>',
deploymentCredentialId: '<string>',
includeCostData: true,
deployAccountIds: ['<string>'],
deployRolePolicyArns: ['<string>'],
deployRolePermissionsBoundaryArn: '<string>',
deployProjectIds: ['<string>'],
deployTrustedPrincipalArn: '<string>',
organizationUnitIds: ['<string>'],
templateRepository: '<string>',
templateRevision: '<string>',
templatePath: '<string>',
projectName: '<string>',
environmentName: '<string>'
})
};
fetch('https://api.env0.com/aws-access-setups', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.env0.com/aws-access-setups",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'organizationId' => '<string>',
'deploymentCredentialId' => '<string>',
'includeCostData' => true,
'deployAccountIds' => [
'<string>'
],
'deployRolePolicyArns' => [
'<string>'
],
'deployRolePermissionsBoundaryArn' => '<string>',
'deployProjectIds' => [
'<string>'
],
'deployTrustedPrincipalArn' => '<string>',
'organizationUnitIds' => [
'<string>'
],
'templateRepository' => '<string>',
'templateRevision' => '<string>',
'templatePath' => '<string>',
'projectName' => '<string>',
'environmentName' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.env0.com/aws-access-setups"
payload := strings.NewReader("{\n \"organizationId\": \"<string>\",\n \"deploymentCredentialId\": \"<string>\",\n \"includeCostData\": true,\n \"deployAccountIds\": [\n \"<string>\"\n ],\n \"deployRolePolicyArns\": [\n \"<string>\"\n ],\n \"deployRolePermissionsBoundaryArn\": \"<string>\",\n \"deployProjectIds\": [\n \"<string>\"\n ],\n \"deployTrustedPrincipalArn\": \"<string>\",\n \"organizationUnitIds\": [\n \"<string>\"\n ],\n \"templateRepository\": \"<string>\",\n \"templateRevision\": \"<string>\",\n \"templatePath\": \"<string>\",\n \"projectName\": \"<string>\",\n \"environmentName\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.env0.com/aws-access-setups")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"organizationId\": \"<string>\",\n \"deploymentCredentialId\": \"<string>\",\n \"includeCostData\": true,\n \"deployAccountIds\": [\n \"<string>\"\n ],\n \"deployRolePolicyArns\": [\n \"<string>\"\n ],\n \"deployRolePermissionsBoundaryArn\": \"<string>\",\n \"deployProjectIds\": [\n \"<string>\"\n ],\n \"deployTrustedPrincipalArn\": \"<string>\",\n \"organizationUnitIds\": [\n \"<string>\"\n ],\n \"templateRepository\": \"<string>\",\n \"templateRevision\": \"<string>\",\n \"templatePath\": \"<string>\",\n \"projectName\": \"<string>\",\n \"environmentName\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.env0.com/aws-access-setups")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"organizationId\": \"<string>\",\n \"deploymentCredentialId\": \"<string>\",\n \"includeCostData\": true,\n \"deployAccountIds\": [\n \"<string>\"\n ],\n \"deployRolePolicyArns\": [\n \"<string>\"\n ],\n \"deployRolePermissionsBoundaryArn\": \"<string>\",\n \"deployProjectIds\": [\n \"<string>\"\n ],\n \"deployTrustedPrincipalArn\": \"<string>\",\n \"organizationUnitIds\": [\n \"<string>\"\n ],\n \"templateRepository\": \"<string>\",\n \"templateRevision\": \"<string>\",\n \"templatePath\": \"<string>\",\n \"projectName\": \"<string>\",\n \"environmentName\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"setupId": "<string>",
"organizationId": "<string>",
"accountMode": "single",
"includeCostData": true,
"deployAccountIds": [
"<string>"
],
"deploySignInMethod": "oidc",
"draftId": "<string>",
"projectId": "<string>",
"environmentId": "<string>",
"deploymentLogId": "<string>",
"status": "planning",
"deployCredentials": [
{
"awsAccountId": "<string>",
"credentialId": "<string>"
}
],
"deployRolePolicyArns": [
"<string>"
],
"deployRolePermissionsBoundaryArn": "<string>",
"deployProjectIds": [
"<string>"
],
"deployTrustedPrincipalArn": "<string>",
"templateRepository": "<string>",
"templateRevision": "<string>",
"templateRef": "<string>",
"templatePath": "<string>",
"planSummary": {
"added": 123,
"changed": 123,
"destroyed": 123
},
"failure": {
"phase": "plan",
"message": "<string>"
},
"approvalsPending": true,
"readRoleFailures": [
{
"awsAccountId": "<string>",
"status": "<string>",
"detailedStatus": "<string>",
"reason": "<string>"
}
],
"readRoleRepair": true,
"readRolesRepairedAt": "<string>",
"readRolesUnchecked": "self_hosted_agent",
"cloudCompassCredentialId": "<string>"
}Authorizations
env zero API authentication is done via API keys. An API Key can either be created by an organization administrator, in which case it will not be connected to any specific user, or via Personal API Keys to authenticate as a user.
Creating an API Key with a Specific Role
- Once you've created your organization, you can set up and manage API Keys.
- Navigate to the Organization Settings page and click the API Keys tab.
- Click Add API Key and enter a name for your key in the Name field. This name is for reference purposes only and isn't used directly in authentication.
❗️Save Your API Key ID and secret The secret will not be available after you close this window.
Creating a Personal API Key
- Click on your avatar (located on the top right of the screen)
- Click on Personal Settings
- Select the API Keys tab
- Click Add API Key, and enter a name for your key in the Name field. This name is for reference purposes and isn't used directly in authentication.
❗️Save your API Key ID & secret The secret will not be available after you close this window.
Using an API Key to Authenticate
Authentication of the env zero API is done using the Basic Authentication method. Each request made should include the API Key ID as the username, and the API Key secret as the password. For example, when using curl, we can include these parameters via flag --user {API Key ID}:{API Key Secret}.
API Key Permissions
When creating an API key through the organization settings, you will need to choose if you’d like to grant it Organization Admin or User permissions. In case of the latter, you can assign fine-grained permissions per project. Personal API Keys can be created through the user’s profile page and will have the same permissions as the user has.
Rate Limits
env zero API allows up to 1K requests per 60 seconds, requests are aggregated by IP, HTTP Method and URI. If you exceed this limit, you will receive a 429 status code.
Body
Organization mode only, needed with deployAccountIds unless deployTrustedPrincipalArn is given: the env zero projects whose deployments may sign in to the deploy roles. AWS refuses any other project's deployments; adding a project means a Retry with the new list.
20An env zero project ID, as the deploy roles' trust names it.
^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$Organization mode only: the OUs Cloud Compass reads, picked before the apply. Empty reads the whole Organization. With it, env zero creates the Cloud Compass credential once the apply finishes, as it does for one account; without it, the client picks the OUs then.
1000^(ou-[0-9a-z]{4,32}-[a-z0-9]{8,32}|r-[0-9a-z]{4,32})$Any public GitHub repository to deploy instead of env zero's template, such as a fork of env0/setup. It must keep the template's variables and outputs. Needs the CREATE_AND_EDIT_TEMPLATES permission, since its code runs with the deployment credential.
^https://github\.com/[A-Za-z0-9][A-Za-z0-9-]{0,38}/(?!\.\.?$)[A-Za-z0-9._-]{1,100}$With templateRepository only: the branch, tag or commit to deploy. Defaults to the repository's default branch. Start resolves it to a commit, and Retries deploy that commit, except after the repository lacked the template's outputs: that Retry resolves it again, so a fix pushed to it deploys.
255^(?![-/])(?!.*\.\.)[\w./-]*[\w.-]$The name of the project env zero makes for the setup. Defaults to "env zero setup". A deployment credential's setups share one project, so a later setup with the same credential goes in that project, and a different name is refused. A name another project has is refused too.
100^\S(.*\S)?$Response
Organization mode, done only: the member accounts whose read role stack is not current, read from AWS with the deploying credential. Empty when env zero read them and none failed; left out when it could not read them. A done setup with any can be retried with repairReadRoles, which deploys the member read roles again.
Show child attributes
Show child attributes
done, Organization mode, when env zero did not read the member read roles. self_hosted_agent: the deploying role trusts a self-hosted agent, which env zero cannot stand in for, so it never reads them. no_sign_in: the deploying credential is gone or the organization turned OIDC off, so no read works until that changes. read_failed: the read failed or AWS answered too slowly; a later read may work.
self_hosted_agent, no_sign_in, read_failed Was this page helpful?