How to Onboard Single AWS Account via terraform in Prisma Cloud

How to Onboard Single AWS Account via terraform in Prisma Cloud

1761
Created On 06/28/22 23:01 PM - Last Modified 04/17/24 05:43 AM


Objective


Onboard single AWS cloud account using terraform template instead of AWS Cloud Formation Template

Environment


  • Prisma Cloud
  • AWS Onboarding
  • Terraform


Procedure


Steps to onboard a single AWS Cloud Account using Terraform template:

  1.  Begin with the main.tf script as shown in our API terraform documentation here.
  2.  In the ".prismacloud_auth.json" credentials file, replace "api.eu.prismacloud.io" with "api3.prismacloud.io" for API access (not console access).
  3.  Create Prisma API access tokens with "System Admin" privileges. Any other role cannot create an account.
  4.  Generate a JWT token for Prisma API access using the following curl command and the Access Tokens from step 3:
curl -X POST \
https://api3.prismacloud.io/login \
-H 'Content-Type: application/json' \
-d '{"username":"11111111","password":"22222222"}'
  1. Derive the account group UUIDs needed for step 6 using the following python script, replacing 33333333 with the token from step 4.

import requests
url = "https://api3.prismacloud.io/cloud/group"
querystring = {"excludeCloudAccountDetails":"false"}
headers = {"x-redlock-auth":"33333333"}
response = requests.request("GET", url, headers=headers,
params=querystring)
print(response.text)
  1. Remove the second resource from main.tf above using the following snippet. It will create an account group, rather than using an existing one.

resource "prismacloud_account_group" "g1" {
name = "My group"
}
  1.  Instead use the following syntax within the account resource creation section. Replace 111122223333444 with real account group UUIDs (see step 5)

group_ids = [
"1111222233334444"
]
  1.  Run terraform and apply

terraform init
terraform fmt
terraform validate
terraform apply
to create a new Prisma account, and have it included in a Prisma account group.

 


Additional Information


Prisma Cloud Terraform Template GitHub reference

Actions
  • Print
  • Copy Link

    https://knowledgebase.paloaltonetworks.com/KCSArticleDetail?id=kA14u000000CqFwCAK&lang=en_US&refURL=http%3A%2F%2Fknowledgebase.paloaltonetworks.com%2FKCSArticleDetail