3c Terraform TLS Provider
3c Terraform TLS Provider
The Terraform TLS provider provides utilities for working with Transport Layer Security keys and
certificates. It provides resources that allow private keys, certificates and certficate requests to be
created as part of a Terraform deployment.
terraform -version
Terraform v1.0.8
Edit the file titled terraform.tf to add the Terraform TLS provider.
terraform.tf
terraform {
required_version = ">= 1.0.0"
required_providers {
aws = {
source = "hashicorp/aws"
}
http = {
source = "hashicorp/http"
version = "2.1.0"
}
random = {
source = "hashicorp/random"
version = "3.1.0"
}
local = {
source = "hashicorp/local"
version = "2.1.0"
1
}
tls = {
source = "hashicorp/tls"
version = "3.1.0"
}
}
}
terraform init
This informs Terraform that it will install the TLS provider for working with Transport Layer Security
keys and certificates.
terraform version
Terraform v1.0.8
on linux_amd64
+ provider registry.terraform.io/hashicorp/aws v3.62.0
+ provider registry.terraform.io/hashicorp/http v2.1.0
+ provider registry.terraform.io/hashicorp/local v2.1.0
+ provider registry.terraform.io/hashicorp/random v3.1.0
+ provider registry.terraform.io/hashicorp/tls v3.1.0
Update the main.tf file with the followig configuration blocks for generating a TLS self signed certifi-
cate and saving the private key locally.
Note: This example creates a self-signed certificate for a development environment. THIS IS NOT
RECOMMENDED FOR PRODUCTION SERVICES.
2
terraform apply
Validate you now have a self-signed private key inside your current working directory name
MyAWSKey.pem
ls -la
cat MyAWSKey.pem
3
-----END RSA PRIVATE KEY-----
We will use this private key in a future lab for associating with our server instances and using it for a
means of authentication.