1. Packages
  2. AWS
  3. API Docs
  4. iot
  5. ThingPrincipalAttachment
AWS v6.77.1 published on Friday, Apr 18, 2025 by Pulumi

aws.iot.ThingPrincipalAttachment

Explore with Pulumi AI

Attaches Principal to AWS IoT Thing.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as std from "@pulumi/std";

const example = new aws.iot.Thing("example", {name: "example"});
const cert = new aws.iot.Certificate("cert", {
    csr: std.file({
        input: "csr.pem",
    }).then(invoke => invoke.result),
    active: true,
});
const att = new aws.iot.ThingPrincipalAttachment("att", {
    principal: cert.arn,
    thing: example.name,
});
Copy
import pulumi
import pulumi_aws as aws
import pulumi_std as std

example = aws.iot.Thing("example", name="example")
cert = aws.iot.Certificate("cert",
    csr=std.file(input="csr.pem").result,
    active=True)
att = aws.iot.ThingPrincipalAttachment("att",
    principal=cert.arn,
    thing=example.name)
Copy
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iot"
	"github.com/pulumi/pulumi-std/sdk/go/std"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		example, err := iot.NewThing(ctx, "example", &iot.ThingArgs{
			Name: pulumi.String("example"),
		})
		if err != nil {
			return err
		}
		invokeFile, err := std.File(ctx, &std.FileArgs{
			Input: "csr.pem",
		}, nil)
		if err != nil {
			return err
		}
		cert, err := iot.NewCertificate(ctx, "cert", &iot.CertificateArgs{
			Csr:    pulumi.String(invokeFile.Result),
			Active: pulumi.Bool(true),
		})
		if err != nil {
			return err
		}
		_, err = iot.NewThingPrincipalAttachment(ctx, "att", &iot.ThingPrincipalAttachmentArgs{
			Principal: cert.Arn,
			Thing:     example.Name,
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
using Std = Pulumi.Std;

return await Deployment.RunAsync(() => 
{
    var example = new Aws.Iot.Thing("example", new()
    {
        Name = "example",
    });

    var cert = new Aws.Iot.Certificate("cert", new()
    {
        Csr = Std.File.Invoke(new()
        {
            Input = "csr.pem",
        }).Apply(invoke => invoke.Result),
        Active = true,
    });

    var att = new Aws.Iot.ThingPrincipalAttachment("att", new()
    {
        Principal = cert.Arn,
        Thing = example.Name,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.iot.Thing;
import com.pulumi.aws.iot.ThingArgs;
import com.pulumi.aws.iot.Certificate;
import com.pulumi.aws.iot.CertificateArgs;
import com.pulumi.std.StdFunctions;
import com.pulumi.std.inputs.FileArgs;
import com.pulumi.aws.iot.ThingPrincipalAttachment;
import com.pulumi.aws.iot.ThingPrincipalAttachmentArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var example = new Thing("example", ThingArgs.builder()
            .name("example")
            .build());

        var cert = new Certificate("cert", CertificateArgs.builder()
            .csr(StdFunctions.file(FileArgs.builder()
                .input("csr.pem")
                .build()).result())
            .active(true)
            .build());

        var att = new ThingPrincipalAttachment("att", ThingPrincipalAttachmentArgs.builder()
            .principal(cert.arn())
            .thing(example.name())
            .build());

    }
}
Copy
resources:
  example:
    type: aws:iot:Thing
    properties:
      name: example
  cert:
    type: aws:iot:Certificate
    properties:
      csr:
        fn::invoke:
          function: std:file
          arguments:
            input: csr.pem
          return: result
      active: true
  att:
    type: aws:iot:ThingPrincipalAttachment
    properties:
      principal: ${cert.arn}
      thing: ${example.name}
Copy

Create ThingPrincipalAttachment Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new ThingPrincipalAttachment(name: string, args: ThingPrincipalAttachmentArgs, opts?: CustomResourceOptions);
@overload
def ThingPrincipalAttachment(resource_name: str,
                             args: ThingPrincipalAttachmentArgs,
                             opts: Optional[ResourceOptions] = None)

@overload
def ThingPrincipalAttachment(resource_name: str,
                             opts: Optional[ResourceOptions] = None,
                             principal: Optional[str] = None,
                             thing: Optional[str] = None)
func NewThingPrincipalAttachment(ctx *Context, name string, args ThingPrincipalAttachmentArgs, opts ...ResourceOption) (*ThingPrincipalAttachment, error)
public ThingPrincipalAttachment(string name, ThingPrincipalAttachmentArgs args, CustomResourceOptions? opts = null)
public ThingPrincipalAttachment(String name, ThingPrincipalAttachmentArgs args)
public ThingPrincipalAttachment(String name, ThingPrincipalAttachmentArgs args, CustomResourceOptions options)
type: aws:iot:ThingPrincipalAttachment
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. ThingPrincipalAttachmentArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. ThingPrincipalAttachmentArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. ThingPrincipalAttachmentArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. ThingPrincipalAttachmentArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. ThingPrincipalAttachmentArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var thingPrincipalAttachmentResource = new Aws.Iot.ThingPrincipalAttachment("thingPrincipalAttachmentResource", new()
{
    Principal = "string",
    Thing = "string",
});
Copy
example, err := iot.NewThingPrincipalAttachment(ctx, "thingPrincipalAttachmentResource", &iot.ThingPrincipalAttachmentArgs{
	Principal: pulumi.String("string"),
	Thing:     pulumi.String("string"),
})
Copy
var thingPrincipalAttachmentResource = new ThingPrincipalAttachment("thingPrincipalAttachmentResource", ThingPrincipalAttachmentArgs.builder()
    .principal("string")
    .thing("string")
    .build());
Copy
thing_principal_attachment_resource = aws.iot.ThingPrincipalAttachment("thingPrincipalAttachmentResource",
    principal="string",
    thing="string")
Copy
const thingPrincipalAttachmentResource = new aws.iot.ThingPrincipalAttachment("thingPrincipalAttachmentResource", {
    principal: "string",
    thing: "string",
});
Copy
type: aws:iot:ThingPrincipalAttachment
properties:
    principal: string
    thing: string
Copy

ThingPrincipalAttachment Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The ThingPrincipalAttachment resource accepts the following input properties:

Principal
This property is required.
Changes to this property will trigger replacement.
string
The AWS IoT Certificate ARN or Amazon Cognito Identity ID.
Thing
This property is required.
Changes to this property will trigger replacement.
string
The name of the thing.
Principal
This property is required.
Changes to this property will trigger replacement.
string
The AWS IoT Certificate ARN or Amazon Cognito Identity ID.
Thing
This property is required.
Changes to this property will trigger replacement.
string
The name of the thing.
principal
This property is required.
Changes to this property will trigger replacement.
String
The AWS IoT Certificate ARN or Amazon Cognito Identity ID.
thing
This property is required.
Changes to this property will trigger replacement.
String
The name of the thing.
principal
This property is required.
Changes to this property will trigger replacement.
ARN
The AWS IoT Certificate ARN or Amazon Cognito Identity ID.
thing
This property is required.
Changes to this property will trigger replacement.
string
The name of the thing.
principal
This property is required.
Changes to this property will trigger replacement.
str
The AWS IoT Certificate ARN or Amazon Cognito Identity ID.
thing
This property is required.
Changes to this property will trigger replacement.
str
The name of the thing.
principal
This property is required.
Changes to this property will trigger replacement.
The AWS IoT Certificate ARN or Amazon Cognito Identity ID.
thing
This property is required.
Changes to this property will trigger replacement.
String
The name of the thing.

Outputs

All input properties are implicitly available as output properties. Additionally, the ThingPrincipalAttachment resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.

Look up Existing ThingPrincipalAttachment Resource

Get an existing ThingPrincipalAttachment resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: ThingPrincipalAttachmentState, opts?: CustomResourceOptions): ThingPrincipalAttachment
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        principal: Optional[str] = None,
        thing: Optional[str] = None) -> ThingPrincipalAttachment
func GetThingPrincipalAttachment(ctx *Context, name string, id IDInput, state *ThingPrincipalAttachmentState, opts ...ResourceOption) (*ThingPrincipalAttachment, error)
public static ThingPrincipalAttachment Get(string name, Input<string> id, ThingPrincipalAttachmentState? state, CustomResourceOptions? opts = null)
public static ThingPrincipalAttachment get(String name, Output<String> id, ThingPrincipalAttachmentState state, CustomResourceOptions options)
resources:  _:    type: aws:iot:ThingPrincipalAttachment    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
Principal Changes to this property will trigger replacement. string
The AWS IoT Certificate ARN or Amazon Cognito Identity ID.
Thing Changes to this property will trigger replacement. string
The name of the thing.
Principal Changes to this property will trigger replacement. string
The AWS IoT Certificate ARN or Amazon Cognito Identity ID.
Thing Changes to this property will trigger replacement. string
The name of the thing.
principal Changes to this property will trigger replacement. String
The AWS IoT Certificate ARN or Amazon Cognito Identity ID.
thing Changes to this property will trigger replacement. String
The name of the thing.
principal Changes to this property will trigger replacement. ARN
The AWS IoT Certificate ARN or Amazon Cognito Identity ID.
thing Changes to this property will trigger replacement. string
The name of the thing.
principal Changes to this property will trigger replacement. str
The AWS IoT Certificate ARN or Amazon Cognito Identity ID.
thing Changes to this property will trigger replacement. str
The name of the thing.
principal Changes to this property will trigger replacement.
The AWS IoT Certificate ARN or Amazon Cognito Identity ID.
thing Changes to this property will trigger replacement. String
The name of the thing.

Package Details

Repository
AWS Classic pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.