Skip to content

Resource: awsIotPolicyAttachment

Provides an IoT policy attachment.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const awsIotCertificateCert = new aws.iotCertificate.IotCertificate(
  this,
  "cert",
  {
    active: true,
    csr: '${file("csr.pem")}',
  }
);
const dataAwsIamPolicyDocumentPubsub =
  new aws.dataAwsIamPolicyDocument.DataAwsIamPolicyDocument(this, "pubsub", {
    statement: [
      {
        actions: ["iot:*"],
        effect: "Allow",
        resources: ["*"],
      },
    ],
  });
const awsIotPolicyPubsub = new aws.iotPolicy.IotPolicy(this, "pubsub_2", {
  name: "PubSubToAnyTopic",
  policy: dataAwsIamPolicyDocumentPubsub.json,
});
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsIotPolicyPubsub.overrideLogicalId("pubsub");
new aws.iotPolicyAttachment.IotPolicyAttachment(this, "att", {
  policy: awsIotPolicyPubsub.name,
  target: awsIotCertificateCert.arn,
});

Argument Reference

The following arguments are supported:

  • policy - (Required) The name of the policy to attach.
  • target - (Required) The identity to which the policy is attached.

Attributes Reference

No additional attributes are exported.