1. Packages
  2. AWS Classic
  3. API Docs
  4. iot
  5. ThingPrincipalAttachment

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.24.0 published on Tuesday, Feb 27, 2024 by Pulumi

aws.iot.ThingPrincipalAttachment

Explore with Pulumi AI

aws logo

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.24.0 published on Tuesday, Feb 27, 2024 by Pulumi

    Attaches Principal to AWS IoT Thing.

    Example Usage

    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var example = new Aws.Iot.Thing("example");
    
        var cert = new Aws.Iot.Certificate("cert", new()
        {
            Csr = File.ReadAllText("csr.pem"),
            Active = true,
        });
    
        var att = new Aws.Iot.ThingPrincipalAttachment("att", new()
        {
            Principal = cert.Arn,
            Thing = example.Name,
        });
    
    });
    
    package main
    
    import (
    	"os"
    
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iot"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func readFileOrPanic(path string) pulumi.StringPtrInput {
    	data, err := os.ReadFile(path)
    	if err != nil {
    		panic(err.Error())
    	}
    	return pulumi.String(string(data))
    }
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		example, err := iot.NewThing(ctx, "example", nil)
    		if err != nil {
    			return err
    		}
    		cert, err := iot.NewCertificate(ctx, "cert", &iot.CertificateArgs{
    			Csr:    readFileOrPanic("csr.pem"),
    			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
    	})
    }
    
    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.Certificate;
    import com.pulumi.aws.iot.CertificateArgs;
    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");
    
            var cert = new Certificate("cert", CertificateArgs.builder()        
                .csr(Files.readString(Paths.get("csr.pem")))
                .active(true)
                .build());
    
            var att = new ThingPrincipalAttachment("att", ThingPrincipalAttachmentArgs.builder()        
                .principal(cert.arn())
                .thing(example.name())
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_aws as aws
    
    example = aws.iot.Thing("example")
    cert = aws.iot.Certificate("cert",
        csr=(lambda path: open(path).read())("csr.pem"),
        active=True)
    att = aws.iot.ThingPrincipalAttachment("att",
        principal=cert.arn,
        thing=example.name)
    
    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    import * as fs from "fs";
    
    const example = new aws.iot.Thing("example", {});
    const cert = new aws.iot.Certificate("cert", {
        csr: fs.readFileSync("csr.pem", "utf8"),
        active: true,
    });
    const att = new aws.iot.ThingPrincipalAttachment("att", {
        principal: cert.arn,
        thing: example.name,
    });
    
    resources:
      example:
        type: aws:iot:Thing
      cert:
        type: aws:iot:Certificate
        properties:
          csr:
            fn::readFile: csr.pem
          active: true
      att:
        type: aws:iot:ThingPrincipalAttachment
        properties:
          principal: ${cert.arn}
          thing: ${example.name}
    

    Create ThingPrincipalAttachment Resource

    new ThingPrincipalAttachment(name: string, args: ThingPrincipalAttachmentArgs, opts?: CustomResourceOptions);
    @overload
    def ThingPrincipalAttachment(resource_name: str,
                                 opts: Optional[ResourceOptions] = None,
                                 principal: Optional[str] = None,
                                 thing: Optional[str] = None)
    @overload
    def ThingPrincipalAttachment(resource_name: str,
                                 args: ThingPrincipalAttachmentArgs,
                                 opts: Optional[ResourceOptions] = 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.
    
    
    name string
    The unique name of the resource.
    args ThingPrincipalAttachmentArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args 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 string
    The unique name of the resource.
    args ThingPrincipalAttachmentArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args ThingPrincipalAttachmentArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args ThingPrincipalAttachmentArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    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

    The ThingPrincipalAttachment resource accepts the following input properties:

    Principal string
    The AWS IoT Certificate ARN or Amazon Cognito Identity ID.
    Thing string
    The name of the thing.
    Principal string
    The AWS IoT Certificate ARN or Amazon Cognito Identity ID.
    Thing string
    The name of the thing.
    principal String
    The AWS IoT Certificate ARN or Amazon Cognito Identity ID.
    thing String
    The name of the thing.
    principal ARN
    The AWS IoT Certificate ARN or Amazon Cognito Identity ID.
    thing string
    The name of the thing.
    principal str
    The AWS IoT Certificate ARN or Amazon Cognito Identity ID.
    thing str
    The name of the thing.
    principal
    The AWS IoT Certificate ARN or Amazon Cognito Identity ID.
    thing 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)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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 string
    The AWS IoT Certificate ARN or Amazon Cognito Identity ID.
    Thing string
    The name of the thing.
    Principal string
    The AWS IoT Certificate ARN or Amazon Cognito Identity ID.
    Thing string
    The name of the thing.
    principal String
    The AWS IoT Certificate ARN or Amazon Cognito Identity ID.
    thing String
    The name of the thing.
    principal ARN
    The AWS IoT Certificate ARN or Amazon Cognito Identity ID.
    thing string
    The name of the thing.
    principal str
    The AWS IoT Certificate ARN or Amazon Cognito Identity ID.
    thing str
    The name of the thing.
    principal
    The AWS IoT Certificate ARN or Amazon Cognito Identity ID.
    thing 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.
    aws logo

    Try AWS Native preview for resources not in the classic version.

    AWS Classic v6.24.0 published on Tuesday, Feb 27, 2024 by Pulumi