As mentioned in the Usage section of the readme, the cdp-tf-quickstarts repository demonstrates how to deploy CDP end-to-end in a simplified way, using the modules in this repository. If you would like to customize your setup however, you may want to change some of the module code. To make sure you can test your changes locally and create customized deployments, we recommend the following setup:
- Create a directory called
tf
and clone the Quickstart module repository
mkdir tf
cd tf
git clone https://github.com/cloudera-labs/cdp-tf-quickstarts.git
This will result in the directory structure below:
tree -L 4
.
└── tf
└── cdp-tf-quickstarts
├── LICENSE
├── README.md
├── aws
│ ├── main.tf
│ ├── terraform.tfvars.template
│ └── variables.tf
└── azure
├── main.tf
├── terraform.tfvars.template
└── variables.tf
The cdp-tf-quickstarts module consists of these few files only. This is achieved by loading the required submodules dynamically in the main.tf
file:
module "cdp_aws_prereqs" {
source = "git::https://github.com/cloudera-labs/terraform-cdp-modules.git//modules/terraform-cdp-aws-pre-reqs?ref=v0.1.0"
…
}
- For a local development environment these modules should be present locally. Make sure we are in the same project folder as earlier and clone this repository
cd ~/tf
git clone https://github.com/cloudera-labs/terraform-cdp-modules.git
This will result in the following directory structure with the two cloned repositories:
cd ~
tree -L 4
.
└── tf
├── cdp-tf-quickstarts
│ ├── LICENSE
│ ├── README.md
│ ├── aws
│ │ ├── main.tf
│ │ ├── terraform.tfvars.template
│ │ └── variables.tf
│ └── azure
│ ├── main.tf
│ ├── terraform.tfvars.template
│ └── variables.tf
└── terraform-cdp-modules
├── LICENSE
├── README.md
└── modules
├── terraform-cdp-aws-pre-reqs
├── terraform-cdp-azure-pre-reqs
└── terraform-cdp-deploy
- The last step for setting up the local cdependencies is to link the two modules. To do this, simply edit the two main.tf files of the cdp-tf-quickstarts module.
vi ~/tf/cdp-tf-quickstarts/aws/main.tf
# Change the first line of code in both "module" blocks:
# from
source = "git::https://github.com/cloudera-labs/terraform-cdp-modules.git//modules/terraform-cdp-aws-pre-reqs?ref=v0.2.0"
# to
source = "../../terraform-cdp-modules/modules/terraform-cdp-aws-pre-reqs"
# and from
source = "git::https://github.com/cloudera-labs/terraform-cdp-modules.git//modules/terraform-cdp-deploy?ref=v0.2.0"
# to
source = "../../terraform-cdp-modules/modules/terraform-cdp-deploy"
Same as above, just change the first module’s source to source = "../../terraform-cdp-modules/modules/terraform-cdp-azure-pre-reqs"
The CDP provider offers a flexible means of providing credentials for authentication. The following methods are supported:
- Static credentials
- Environment variables
- Shared credentials file
See the CDP Terraform Provider Documentation for more details on each of these authentication methods.
The CDP Control Plane Region associated with a set of CDP credentials can be specified via one of the following methods:
- Set the control plane region name in the CDP provider configuration of the Terraform root module as shown below.
provider "cdp" {
# Example of setting control plane region to eu-1
cdp_region = "eu-1"
}
- Set the
CDP_REGION
environment variable in your terminal, e.g.:
export CDP_REGION="eu-1"
- Set cdp_region in your CDP config file (
~/.cdp/config
). Below shows an example for the default profile and for a custom profile.
[default]
cdp_region = us-west-1
[profile customprofile]
cdp_region = eu-1
See CDP Terraform Provider Documentation for further details on setting the CDP region
When using a shared credentials file a custom profile (other than default
) can be specified via one of the following methods:
- Set the profile name in the CDP provider configuration of the Terraform root module as shown below.
provider "cdp" {
cdp_profile = "customprofile"
}
- Set the
CDP_PROFILE
environment variable in your terminal, e.g.
export CDP_PROFILE="customprofile"