
Using Terraform to create AWS IoT Things
In this post users will learn to use Terraform to create AWS IoT Certificates and a Policy attached to the Certificates and create AWS IoT Things created with these Certificates attached.
Terraform is a widely using Infrastructure as Code tool to manage Cloud infrastructure. This post will introduce you to use Terraform as Infrastructure-as-Code (IaC) tool to create 1/ IoT Policy, 2/ a new Certificate with the IoT policy attached to this Certificate, and 3/ create an IoT Thing with the Certificate attached.
Terraform code shared in this github repository will help you create unique Certificates for each IoT Thing defined in the configuration file. A template of IoT policy created is shown in the code block. It enforces to publish & subscribe to a topic defined in the code as shown in the code block, and connect with thing name used while creating IoT Thing.
{ "Statement": [ { "Action": "iot:Connect", "Effect": "Allow", "Resource": "arn:aws:iot:REGION:ACCOUNT_NUMBER:client/${iot:Connection.Thing.ThingName}", "Sid": "ClientConnectRestrictred" }, { "Action": [ "iot:Receive", "iot:Publish" ], "Effect": "Allow", "Resource": "arn:aws:iot:REGION:ACCOUNT_NUMBER:topic/TOPIC_NAME/${iot:Connection.Thing.ThingName}", "Sid": "PublishReceivePermissions" }, { "Action": "iot:Subscribe", "Effect": "Allow", "Resource": "arn:aws:iot:REGION:ACCOUNT_NUMBER:topicfilter/TOPIC_NAME/${iot:Connection.Thing.ThingName}", "Sid": "SubscribePermissions" } ], "Version": "2012-10-17"}IoT devices connect to AWS IoT Core using these certificates, hence we create a unique certificate for each device. Policy defined in the code improves security. This policy will allow IoT devices connect to AWS IoT core using MQTT ClientID with the thing name defined. This policy also enforces Publish and Subscribe to a topic as defined in the Resource section of the Statement in the code block.
Note: Certificates are stored as sensitive data in Terraform state file and Terraform output command can be used to retrieve these Certificates.
Prerequisites:
- An active AWS account.
- AWS Command Line Interface (AWS CLI) configured.
- Set the AWS environment variables ‘AWS_ACCESS_KEY_ID‘, ‘AWS_SECRET_ACCESS_KEY‘, ‘AWS_SESSION_TOKEN‘ and ‘AWS_DEFAULT_REGION‘.
- Use this link to learn more about setting Environment variables.
- git and Terraform installed.
To use this code in production environment all the Terraform state files should be stored in Amazon Simple Storage Service (Amazon S3) buckets, a Git repo or other secure storage. Enable versioning when using S3 buckets.
Steps to create IoT things using this repo
- Verify AWS Environment variables are set and check the role assumed.
bash-5.2$ aws sts get-caller-identity{ "UserId": "ARORABOBATEAMANGO2NP:atulchaudhari", "Account": "202406231234", "Arn": "arn:aws:sts::202406231234:assumed-role/IoTAdmin/atulchaudhari"}- Create a tfvars file as shown below with AWS Account number and AWS region where the AWS IoT things and certificates need to be created. Set the name of the AWS IoT Policy that should be created and attached to the AWS IoT X.509 certificates that will be created. Set the AWS IoT MQTT Topic to which the IoT Things can publish and subscribe using the Certificate and the Policy.
region = "us-west-2"account = "202406231234"thing_policy = "demoterraformpolicy"topic = "demoterraformtopic"thing = ["thing01", "thing02", "thing03"]In this example.tfvars file 3 IoT things are requested to be created with Policy name "demoterraformpolicy" and MQTT topic "demoterraformtopic"
- Next run
ls -lhto confirm the terraform files and the tfvars file are in the current working directory.
bash-5.2$ ls -lhtotal 96-rw-r--r-- 1 atulac staff 1.0K Jun 23 22:34 LICENSE-rw-r--r-- 1 atulac staff 21K Jun 23 22:40 README.md-rw-r--r-- 1 atulac staff 1.1K Jun 23 22:24 data.tf-rw-r--r-- 1 atulac staff 193B Jun 23 23:35 example.tfvarsdrwxr-xr-x 7 atulac staff 224B Jun 23 22:24 images-rw-r--r-- 1 atulac staff 854B Jun 23 22:24 main.tf-rw-r--r-- 1 atulac staff 662B Jun 23 22:24 output.tf-rw-r--r-- 1 atulac staff 400B Jun 23 22:24 variables.tf- Run
terraform initto initialize the download required provider packages. Your terminal output should look as shown below:
Initializing the backend...
Initializing provider plugins...- Finding latest version of hashicorp/aws...- Finding latest version of hashicorp/http...- Installing hashicorp/aws v5.55.0...- Installed hashicorp/aws v5.55.0 (signed by HashiCorp)- Installing hashicorp/http v3.4.3...- Installed hashicorp/http v3.4.3 (signed by HashiCorp)
Terraform has created a lock file .terraform.lock.hcl to record the providerselections it made above. Include this file in your version control repositoryso that Terraform can guarantee to make the same selections by default whenyou run "terraform init" in the future.
Terraform has been successfully initialized!
You may now begin working with Terraform. Try running "terraform plan" to seeany changes that are required for your infrastructure. All Terraform commandsshould now work.
If you ever set or change modules or backend configuration for Terraform,rerun this command to reinitialize your working directory. If you forget, othercommands will detect it and remind you to do so if necessary.- You can run
terraform plan -var-file=example.tfvarsto review the resources that will be created before creating these resources.
bash-5.2$ terraform plan -var-file=example.tfvars data.http.AmazonRootCA1: Reading...data.http.AmazonRootCA1: Read complete after 0s [id=https://www.amazontrust.com/repository/AmazonRootCA1.pem]data.aws_iam_policy_document.aws_iot_thing_policy: Reading...data.aws_iot_endpoint.thing_ats_mqtt: Reading...data.aws_iam_policy_document.aws_iot_thing_policy: Read complete after 0s [id=4035393401]data.aws_iot_endpoint.thing_ats_mqtt: Read complete after 1s [id=atulcommblog-ats.iot.us-west-2.amazonaws.com]
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: + create
Terraform will perform the following actions:
# aws_iot_certificate.thing[0] will be created + resource "aws_iot_certificate" "thing" { + active = true + arn = (known after apply) + ca_certificate_id = (known after apply) + certificate_pem = (sensitive value) + id = (known after apply) + private_key = (sensitive value) + public_key = (sensitive value) }
# aws_iot_certificate.thing[1] will be created + resource "aws_iot_certificate" "thing" { + active = true + arn = (known after apply) + ca_certificate_id = (known after apply) + certificate_pem = (sensitive value) + id = (known after apply) + private_key = (sensitive value) + public_key = (sensitive value) }
# aws_iot_certificate.thing[2] will be created
... ...
# aws_iot_policy.thing will be created + resource "aws_iot_policy" "thing" { + arn = (known after apply) + default_version_id = (known after apply) + id = (known after apply) + name = "demoterraformpolicy" + policy = jsonencode( { + Statement = [ + { + Action = "iot:Connect" + Effect = "Allow" + Resource = "arn:aws:iot:us-west-2:202406231234:client/${iot:Connection.Thing.ThingName}" + Sid = "ClientConnectRestrictred" }, + { + Action = [ + "iot:Receive", + "iot:Publish", ] + Effect = "Allow" + Resource = "arn:aws:iot:us-west-2:202406231234:topic/demoterraformtopic/${iot:Connection.Thing.ThingName}" + Sid = "PublishReceivePermissions" }, + { + Action = "iot:Subscribe" + Effect = "Allow" + Resource = "arn:aws:iot:us-west-2:202406231234:topicfilter/demoterraformtopic/${iot:Connection.Thing.ThingName}" + Sid = "SubscribePermissions" }, ] + Version = "2012-10-17" } ) + tags_all = (known after apply) }...... Plan: 13 to add, 0 to change, 0 to destroy.
Changes to Outputs: + AmazonRootCA1_response = <<-EOT -----BEGIN CERTIFICATE----- MIIDQTCCAimgAwIBAgITBmyfz5m/jAo54vB4ikPmljZbyjANBgkqhkiG9w0BAQsF ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6 b24gUm9vdCBDQSAxMB4XDTE1MDUyNjAwMDAwMFoXDTM4MDExNzAwMDAwMFowOTEL ... ... 5MsI+yMRQ+hDKXJioaldXgjUkK642M4UwtBV8ob2xJNDd2ZhwLnoQdeXeGADbkpy rqXRfboQnoZsG4q5WTP468SQvvG5 -----END CERTIFICATE----- EOT + iot_endpoint = "atulcommblog-ats.iot.us-west-2.amazonaws.com" + iot_topic = "demoterraformtopic" + thing_arn = [ + (known after apply), + (known after apply), + (known after apply), ] + thing_cert = (sensitive value) + thing_cert_pubkey = (sensitive value) + thing_name = [ + "thing01", + "thing02", + "thing03", ] + thing_pvtkey = (sensitive value)- Finally create the AWS IoT Things using Terraform with
terraform apply -var-file=example.tfvars -auto-approve
bash-5.2$ terraform apply -var-file=example.tfvars -auto-approvedata.http.AmazonRootCA1: Reading...data.http.AmazonRootCA1: Read complete after 0s [id=https://www.amazontrust.com/repository/AmazonRootCA1.pem]data.aws_iam_policy_document.aws_iot_thing_policy: Reading...data.aws_iot_endpoint.thing_ats_mqtt: Reading...data.aws_iam_policy_document.aws_iot_thing_policy: Read complete after 0s [id=1649382831]data.aws_iot_endpoint.thing_ats_mqtt: Read complete after 0s .........
Apply complete! Resources: 13 added, 0 changed, 0 destroyed.
Outputs:
AmazonRootCA1_response = <<EOT-----BEGIN CERTIFICATE-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ADbkpyrqXRfboQnoZsG4q5WTP468SQvvG5-----END CERTIFICATE-----
EOTiot_endpoint = "atulcommblog-ats.iot.us-west-2.amazonaws.com"iot_topic = "demoterraformtopic"thing_arn = [ "arn:aws:iot:us-west-2:202406231234:thing/thing01", "arn:aws:iot:us-west-2:202406231234:thing/thing02", "arn:aws:iot:us-west-2:202406231234:thing/thing03",]thing_cert = <sensitive>thing_cert_pubkey = <sensitive>thing_name = [ "thing01", "thing02", "thing03",]thing_pvtkey = <sensitive>- Let's verify them in AWS Console by Login to AWS Console and search for AWS IoT core in search and set the region to US-WEST-2. Expand All devices menu in the left sidebar and click on Things. You should see the newly created Things as listed in the example.tfvars file.

- Click on thing01 to review the Thing created and the Certificate attached. Next click on the certificate id as shown in the screenshot below:

- Certificate shows the AWS IoT policy created as defined in the terraform scripts and attached to AWS IoT Thing thing01.

- The new Policy created shows the permissions as defined in the data.tf terraform file with permissions to allow Connect, Receive, Publish and Subscribe.

- Next the Root CA1 and the AWS IoT Things certificates can be extracted from the output file using these commands
-
terraform output -json | jq -r '.AmazonRootCA1_response.value'to show the Amazon Root CA1.
-
terraform output -json | jq -r '.thing_cert.value[]'to show the list of X.509 certificates.
-
terraform output -json | jq -r '.thing_pvtkey.value[]'to show the list of private certificates.
bash-5.2$ terraform output -json | jq -r '.AmazonRootCA1_response.value'-----BEGIN CERTIFICATE-----MIIDQTCCAimgAwIBAgITBmyfz5m/jAo54vB4ikPmljZbyjANBgkqhkiG9w0BAQsFADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSAxMB4XDTE1MDUyNjAwMDAwMFoXDTM4MDExNzAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALJ4gHHKeNXjca9HgFB0fW7Y14h29Jlo91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HMlI6ceBXVNr6WqrohGfmHWC91iQYj3ya6UrB4kjfIUGvnQ9bIj1pE+nHzTnA3jIvQ6gCHBCfJupb6W1yw2nOHxPnEO1g==-----END CERTIFICATE-----
bash-5.2$ terraform output -json | jq -r '.thing_pvtkey.value[]'-----BEGIN RSA PRIVATE KEY-----MIIEpAIBAAKCAQEA0jYZQxniTjIhYe+4OrgivQenAxTKebZEn78l7oZCyfK5JlR6lbRpN0G3HFdQcWA7norWq2DHdq1wyxH77DwrLAargUcJqsIe8MHZPBklIl5xRR1ZTyUy1TfFYoxKwL3aFgBWk+15Db50eExcpwTT7PnAEsS61R/3LAc2QNYdJdA1yLxTGvFRsiyyio7985I2OQGJJ3MEmfWlkVERT91WzVQRxKUxgoEZWLcx0r7Mr3K4eFG8g7uecYIk8TEXNdXDwLr8iHvvVznW0qMlLogmryKxRkFOPKsi6kthaX3x7xh38pOa1j5PvrXLz+81RSNRREi9tFnBOizqrmFMyO6u5wIDAQABAoIBADTFJ+pUYR9ILmErkJANEYtqlF6NpZaQTwHbNmZ+hd20dQ5OPse+Fnusn48ZzDPp+I2ARQuYq/n66EnSJe/T2vKeagd2EdMwEBxYTXRsy4mpM74p8/WOXQhxi7eFiG6COnEzfIh+INl2aj6YzNmQuLLQr4sGn/BIqf//f3sfRQnsmlTpccnpFk1TzfEgmq6IMN+CTM18Hy+oMo4EaJgu607zDYnX/wxHA3tl9XmLc5W+ibkK7vggyEIYhHwf4UeuBBIJQiFNXC04KSUvoBiW3GoOOxq8G3E8v55T63Tp18IJgqiDUEccdkBQzrw+dv7x0bc3c3IWE5+fEbJ262F3ZAECgYEA7NqLtSU3CUlHKdiyJwlXxvs1rznKgzi9PqLQWTDGQDj3MD1xbuaOKZgs38oNqWquY1x1acFjyuEBJz1LARTXo3tTtDrZF+ulKV95Ox2phT2iuDy1cAO/OBbiKB2UnVfhib7wYHEl7wdM4jZrjMbNHz4RGURHC1d7FQjg+640fGcCgYEA4zQ3HEIdngRIAvwzq2vlLDY3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vO+iP6xZh+U7rhWnMXsUFmq3MxzCU/Ry5XqGuzb3Wb17Y5VNhAvA5biO+Gtc/WVOfdbLhJNCL+W4cfR8x5xfy2nXpLUHaN8Id+GFmDScLdWgYKJbgjN3rjHvW+r4YNo7sBhQ8UOgrSSsXZHpLYklyGEHsCgYEAv72HHFpkjeSpAvyJuHdQeVs6B0hwH8WRcDjBIgA68M/NzRjyntsJgfINrfzzvJ/ZiBFKL0vFuz+qunpKdwJ9lh/y2umC3W+bze91KLhTWpudwNCYBLzrx3tNQjEqywZXs034R1UItLBjKra0aaviKQgKalEhaMBscdQ8h/4WExcCgYA2Gbt3rXHKvJFYYKr2/7CGd6LRFGm+a6xquV4DiQiHCfntK02HG4UJxneNtU6yDORsWxJGSl6Hsiw+nxAQPSfTUbsU1uw6xWcu55Z9JqYhtxTUYxPFN21bPa9WH0hSu3IcQWsVRxl7P0B3+tCyKGBab5hxqDc2YzBCXOGROMU6lQKBgEFNOi0ifgraWJDk75au+PAVBGzIqsXZQn/ZqpWwWV43QaEkWQjrpRheEFiyVzPX+TMGcuzPXwWxed0BDUb0NBe0e1Lf9t10SOtLbkkm+KYsHxcgYEn+Tmp/VKiEUrwQi1jf2p5u9aTojBouOrCSYs8MMmYsyscbb823YS/NG7U+-----END RSA PRIVATE KEY-----
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article