github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/iot/authorizer.go (about)

     1  // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
     2  // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
     3  
     4  package iot
     5  
     6  import (
     7  	"context"
     8  	"reflect"
     9  
    10  	"errors"
    11  	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
    12  	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    13  )
    14  
    15  // Creates and manages an AWS IoT Authorizer.
    16  //
    17  // ## Example Usage
    18  //
    19  // <!--Start PulumiCodeChooser -->
    20  // ```go
    21  // package main
    22  //
    23  // import (
    24  //
    25  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iot"
    26  //	"github.com/pulumi/pulumi-std/sdk/go/std"
    27  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    28  //
    29  // )
    30  //
    31  //	func main() {
    32  //		pulumi.Run(func(ctx *pulumi.Context) error {
    33  //			invokeFile, err := std.File(ctx, &std.FileArgs{
    34  //				Input: "test-fixtures/iot-authorizer-signing-key.pem",
    35  //			}, nil)
    36  //			if err != nil {
    37  //				return err
    38  //			}
    39  //			_, err = iot.NewAuthorizer(ctx, "example", &iot.AuthorizerArgs{
    40  //				Name:                  pulumi.String("example"),
    41  //				AuthorizerFunctionArn: pulumi.Any(exampleAwsLambdaFunction.Arn),
    42  //				SigningDisabled:       pulumi.Bool(false),
    43  //				Status:                pulumi.String("ACTIVE"),
    44  //				TokenKeyName:          pulumi.String("Token-Header"),
    45  //				TokenSigningPublicKeys: pulumi.StringMap{
    46  //					"Key1": invokeFile.Result,
    47  //				},
    48  //			})
    49  //			if err != nil {
    50  //				return err
    51  //			}
    52  //			return nil
    53  //		})
    54  //	}
    55  //
    56  // ```
    57  // <!--End PulumiCodeChooser -->
    58  //
    59  // ## Import
    60  //
    61  // Using `pulumi import`, import IOT Authorizers using the name. For example:
    62  //
    63  // ```sh
    64  // $ pulumi import aws:iot/authorizer:Authorizer example example
    65  // ```
    66  type Authorizer struct {
    67  	pulumi.CustomResourceState
    68  
    69  	// The ARN of the authorizer.
    70  	Arn pulumi.StringOutput `pulumi:"arn"`
    71  	// The ARN of the authorizer's Lambda function.
    72  	AuthorizerFunctionArn pulumi.StringOutput `pulumi:"authorizerFunctionArn"`
    73  	// Specifies whether the HTTP caching is enabled or not. Default: `false`.
    74  	EnableCachingForHttp pulumi.BoolPtrOutput `pulumi:"enableCachingForHttp"`
    75  	// The name of the authorizer.
    76  	Name pulumi.StringOutput `pulumi:"name"`
    77  	// Specifies whether AWS IoT validates the token signature in an authorization request. Default: `false`.
    78  	SigningDisabled pulumi.BoolPtrOutput `pulumi:"signingDisabled"`
    79  	// The status of Authorizer request at creation. Valid values: `ACTIVE`, `INACTIVE`. Default: `ACTIVE`.
    80  	Status pulumi.StringPtrOutput `pulumi:"status"`
    81  	// The name of the token key used to extract the token from the HTTP headers. This value is required if signing is enabled in your authorizer.
    82  	TokenKeyName pulumi.StringPtrOutput `pulumi:"tokenKeyName"`
    83  	// The public keys used to verify the digital signature returned by your custom authentication service. This value is required if signing is enabled in your authorizer.
    84  	TokenSigningPublicKeys pulumi.StringMapOutput `pulumi:"tokenSigningPublicKeys"`
    85  }
    86  
    87  // NewAuthorizer registers a new resource with the given unique name, arguments, and options.
    88  func NewAuthorizer(ctx *pulumi.Context,
    89  	name string, args *AuthorizerArgs, opts ...pulumi.ResourceOption) (*Authorizer, error) {
    90  	if args == nil {
    91  		return nil, errors.New("missing one or more required arguments")
    92  	}
    93  
    94  	if args.AuthorizerFunctionArn == nil {
    95  		return nil, errors.New("invalid value for required argument 'AuthorizerFunctionArn'")
    96  	}
    97  	if args.TokenSigningPublicKeys != nil {
    98  		args.TokenSigningPublicKeys = pulumi.ToSecret(args.TokenSigningPublicKeys).(pulumi.StringMapInput)
    99  	}
   100  	secrets := pulumi.AdditionalSecretOutputs([]string{
   101  		"tokenSigningPublicKeys",
   102  	})
   103  	opts = append(opts, secrets)
   104  	opts = internal.PkgResourceDefaultOpts(opts)
   105  	var resource Authorizer
   106  	err := ctx.RegisterResource("aws:iot/authorizer:Authorizer", name, args, &resource, opts...)
   107  	if err != nil {
   108  		return nil, err
   109  	}
   110  	return &resource, nil
   111  }
   112  
   113  // GetAuthorizer gets an existing Authorizer resource's state with the given name, ID, and optional
   114  // state properties that are used to uniquely qualify the lookup (nil if not required).
   115  func GetAuthorizer(ctx *pulumi.Context,
   116  	name string, id pulumi.IDInput, state *AuthorizerState, opts ...pulumi.ResourceOption) (*Authorizer, error) {
   117  	var resource Authorizer
   118  	err := ctx.ReadResource("aws:iot/authorizer:Authorizer", name, id, state, &resource, opts...)
   119  	if err != nil {
   120  		return nil, err
   121  	}
   122  	return &resource, nil
   123  }
   124  
   125  // Input properties used for looking up and filtering Authorizer resources.
   126  type authorizerState struct {
   127  	// The ARN of the authorizer.
   128  	Arn *string `pulumi:"arn"`
   129  	// The ARN of the authorizer's Lambda function.
   130  	AuthorizerFunctionArn *string `pulumi:"authorizerFunctionArn"`
   131  	// Specifies whether the HTTP caching is enabled or not. Default: `false`.
   132  	EnableCachingForHttp *bool `pulumi:"enableCachingForHttp"`
   133  	// The name of the authorizer.
   134  	Name *string `pulumi:"name"`
   135  	// Specifies whether AWS IoT validates the token signature in an authorization request. Default: `false`.
   136  	SigningDisabled *bool `pulumi:"signingDisabled"`
   137  	// The status of Authorizer request at creation. Valid values: `ACTIVE`, `INACTIVE`. Default: `ACTIVE`.
   138  	Status *string `pulumi:"status"`
   139  	// The name of the token key used to extract the token from the HTTP headers. This value is required if signing is enabled in your authorizer.
   140  	TokenKeyName *string `pulumi:"tokenKeyName"`
   141  	// The public keys used to verify the digital signature returned by your custom authentication service. This value is required if signing is enabled in your authorizer.
   142  	TokenSigningPublicKeys map[string]string `pulumi:"tokenSigningPublicKeys"`
   143  }
   144  
   145  type AuthorizerState struct {
   146  	// The ARN of the authorizer.
   147  	Arn pulumi.StringPtrInput
   148  	// The ARN of the authorizer's Lambda function.
   149  	AuthorizerFunctionArn pulumi.StringPtrInput
   150  	// Specifies whether the HTTP caching is enabled or not. Default: `false`.
   151  	EnableCachingForHttp pulumi.BoolPtrInput
   152  	// The name of the authorizer.
   153  	Name pulumi.StringPtrInput
   154  	// Specifies whether AWS IoT validates the token signature in an authorization request. Default: `false`.
   155  	SigningDisabled pulumi.BoolPtrInput
   156  	// The status of Authorizer request at creation. Valid values: `ACTIVE`, `INACTIVE`. Default: `ACTIVE`.
   157  	Status pulumi.StringPtrInput
   158  	// The name of the token key used to extract the token from the HTTP headers. This value is required if signing is enabled in your authorizer.
   159  	TokenKeyName pulumi.StringPtrInput
   160  	// The public keys used to verify the digital signature returned by your custom authentication service. This value is required if signing is enabled in your authorizer.
   161  	TokenSigningPublicKeys pulumi.StringMapInput
   162  }
   163  
   164  func (AuthorizerState) ElementType() reflect.Type {
   165  	return reflect.TypeOf((*authorizerState)(nil)).Elem()
   166  }
   167  
   168  type authorizerArgs struct {
   169  	// The ARN of the authorizer's Lambda function.
   170  	AuthorizerFunctionArn string `pulumi:"authorizerFunctionArn"`
   171  	// Specifies whether the HTTP caching is enabled or not. Default: `false`.
   172  	EnableCachingForHttp *bool `pulumi:"enableCachingForHttp"`
   173  	// The name of the authorizer.
   174  	Name *string `pulumi:"name"`
   175  	// Specifies whether AWS IoT validates the token signature in an authorization request. Default: `false`.
   176  	SigningDisabled *bool `pulumi:"signingDisabled"`
   177  	// The status of Authorizer request at creation. Valid values: `ACTIVE`, `INACTIVE`. Default: `ACTIVE`.
   178  	Status *string `pulumi:"status"`
   179  	// The name of the token key used to extract the token from the HTTP headers. This value is required if signing is enabled in your authorizer.
   180  	TokenKeyName *string `pulumi:"tokenKeyName"`
   181  	// The public keys used to verify the digital signature returned by your custom authentication service. This value is required if signing is enabled in your authorizer.
   182  	TokenSigningPublicKeys map[string]string `pulumi:"tokenSigningPublicKeys"`
   183  }
   184  
   185  // The set of arguments for constructing a Authorizer resource.
   186  type AuthorizerArgs struct {
   187  	// The ARN of the authorizer's Lambda function.
   188  	AuthorizerFunctionArn pulumi.StringInput
   189  	// Specifies whether the HTTP caching is enabled or not. Default: `false`.
   190  	EnableCachingForHttp pulumi.BoolPtrInput
   191  	// The name of the authorizer.
   192  	Name pulumi.StringPtrInput
   193  	// Specifies whether AWS IoT validates the token signature in an authorization request. Default: `false`.
   194  	SigningDisabled pulumi.BoolPtrInput
   195  	// The status of Authorizer request at creation. Valid values: `ACTIVE`, `INACTIVE`. Default: `ACTIVE`.
   196  	Status pulumi.StringPtrInput
   197  	// The name of the token key used to extract the token from the HTTP headers. This value is required if signing is enabled in your authorizer.
   198  	TokenKeyName pulumi.StringPtrInput
   199  	// The public keys used to verify the digital signature returned by your custom authentication service. This value is required if signing is enabled in your authorizer.
   200  	TokenSigningPublicKeys pulumi.StringMapInput
   201  }
   202  
   203  func (AuthorizerArgs) ElementType() reflect.Type {
   204  	return reflect.TypeOf((*authorizerArgs)(nil)).Elem()
   205  }
   206  
   207  type AuthorizerInput interface {
   208  	pulumi.Input
   209  
   210  	ToAuthorizerOutput() AuthorizerOutput
   211  	ToAuthorizerOutputWithContext(ctx context.Context) AuthorizerOutput
   212  }
   213  
   214  func (*Authorizer) ElementType() reflect.Type {
   215  	return reflect.TypeOf((**Authorizer)(nil)).Elem()
   216  }
   217  
   218  func (i *Authorizer) ToAuthorizerOutput() AuthorizerOutput {
   219  	return i.ToAuthorizerOutputWithContext(context.Background())
   220  }
   221  
   222  func (i *Authorizer) ToAuthorizerOutputWithContext(ctx context.Context) AuthorizerOutput {
   223  	return pulumi.ToOutputWithContext(ctx, i).(AuthorizerOutput)
   224  }
   225  
   226  // AuthorizerArrayInput is an input type that accepts AuthorizerArray and AuthorizerArrayOutput values.
   227  // You can construct a concrete instance of `AuthorizerArrayInput` via:
   228  //
   229  //	AuthorizerArray{ AuthorizerArgs{...} }
   230  type AuthorizerArrayInput interface {
   231  	pulumi.Input
   232  
   233  	ToAuthorizerArrayOutput() AuthorizerArrayOutput
   234  	ToAuthorizerArrayOutputWithContext(context.Context) AuthorizerArrayOutput
   235  }
   236  
   237  type AuthorizerArray []AuthorizerInput
   238  
   239  func (AuthorizerArray) ElementType() reflect.Type {
   240  	return reflect.TypeOf((*[]*Authorizer)(nil)).Elem()
   241  }
   242  
   243  func (i AuthorizerArray) ToAuthorizerArrayOutput() AuthorizerArrayOutput {
   244  	return i.ToAuthorizerArrayOutputWithContext(context.Background())
   245  }
   246  
   247  func (i AuthorizerArray) ToAuthorizerArrayOutputWithContext(ctx context.Context) AuthorizerArrayOutput {
   248  	return pulumi.ToOutputWithContext(ctx, i).(AuthorizerArrayOutput)
   249  }
   250  
   251  // AuthorizerMapInput is an input type that accepts AuthorizerMap and AuthorizerMapOutput values.
   252  // You can construct a concrete instance of `AuthorizerMapInput` via:
   253  //
   254  //	AuthorizerMap{ "key": AuthorizerArgs{...} }
   255  type AuthorizerMapInput interface {
   256  	pulumi.Input
   257  
   258  	ToAuthorizerMapOutput() AuthorizerMapOutput
   259  	ToAuthorizerMapOutputWithContext(context.Context) AuthorizerMapOutput
   260  }
   261  
   262  type AuthorizerMap map[string]AuthorizerInput
   263  
   264  func (AuthorizerMap) ElementType() reflect.Type {
   265  	return reflect.TypeOf((*map[string]*Authorizer)(nil)).Elem()
   266  }
   267  
   268  func (i AuthorizerMap) ToAuthorizerMapOutput() AuthorizerMapOutput {
   269  	return i.ToAuthorizerMapOutputWithContext(context.Background())
   270  }
   271  
   272  func (i AuthorizerMap) ToAuthorizerMapOutputWithContext(ctx context.Context) AuthorizerMapOutput {
   273  	return pulumi.ToOutputWithContext(ctx, i).(AuthorizerMapOutput)
   274  }
   275  
   276  type AuthorizerOutput struct{ *pulumi.OutputState }
   277  
   278  func (AuthorizerOutput) ElementType() reflect.Type {
   279  	return reflect.TypeOf((**Authorizer)(nil)).Elem()
   280  }
   281  
   282  func (o AuthorizerOutput) ToAuthorizerOutput() AuthorizerOutput {
   283  	return o
   284  }
   285  
   286  func (o AuthorizerOutput) ToAuthorizerOutputWithContext(ctx context.Context) AuthorizerOutput {
   287  	return o
   288  }
   289  
   290  // The ARN of the authorizer.
   291  func (o AuthorizerOutput) Arn() pulumi.StringOutput {
   292  	return o.ApplyT(func(v *Authorizer) pulumi.StringOutput { return v.Arn }).(pulumi.StringOutput)
   293  }
   294  
   295  // The ARN of the authorizer's Lambda function.
   296  func (o AuthorizerOutput) AuthorizerFunctionArn() pulumi.StringOutput {
   297  	return o.ApplyT(func(v *Authorizer) pulumi.StringOutput { return v.AuthorizerFunctionArn }).(pulumi.StringOutput)
   298  }
   299  
   300  // Specifies whether the HTTP caching is enabled or not. Default: `false`.
   301  func (o AuthorizerOutput) EnableCachingForHttp() pulumi.BoolPtrOutput {
   302  	return o.ApplyT(func(v *Authorizer) pulumi.BoolPtrOutput { return v.EnableCachingForHttp }).(pulumi.BoolPtrOutput)
   303  }
   304  
   305  // The name of the authorizer.
   306  func (o AuthorizerOutput) Name() pulumi.StringOutput {
   307  	return o.ApplyT(func(v *Authorizer) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
   308  }
   309  
   310  // Specifies whether AWS IoT validates the token signature in an authorization request. Default: `false`.
   311  func (o AuthorizerOutput) SigningDisabled() pulumi.BoolPtrOutput {
   312  	return o.ApplyT(func(v *Authorizer) pulumi.BoolPtrOutput { return v.SigningDisabled }).(pulumi.BoolPtrOutput)
   313  }
   314  
   315  // The status of Authorizer request at creation. Valid values: `ACTIVE`, `INACTIVE`. Default: `ACTIVE`.
   316  func (o AuthorizerOutput) Status() pulumi.StringPtrOutput {
   317  	return o.ApplyT(func(v *Authorizer) pulumi.StringPtrOutput { return v.Status }).(pulumi.StringPtrOutput)
   318  }
   319  
   320  // The name of the token key used to extract the token from the HTTP headers. This value is required if signing is enabled in your authorizer.
   321  func (o AuthorizerOutput) TokenKeyName() pulumi.StringPtrOutput {
   322  	return o.ApplyT(func(v *Authorizer) pulumi.StringPtrOutput { return v.TokenKeyName }).(pulumi.StringPtrOutput)
   323  }
   324  
   325  // The public keys used to verify the digital signature returned by your custom authentication service. This value is required if signing is enabled in your authorizer.
   326  func (o AuthorizerOutput) TokenSigningPublicKeys() pulumi.StringMapOutput {
   327  	return o.ApplyT(func(v *Authorizer) pulumi.StringMapOutput { return v.TokenSigningPublicKeys }).(pulumi.StringMapOutput)
   328  }
   329  
   330  type AuthorizerArrayOutput struct{ *pulumi.OutputState }
   331  
   332  func (AuthorizerArrayOutput) ElementType() reflect.Type {
   333  	return reflect.TypeOf((*[]*Authorizer)(nil)).Elem()
   334  }
   335  
   336  func (o AuthorizerArrayOutput) ToAuthorizerArrayOutput() AuthorizerArrayOutput {
   337  	return o
   338  }
   339  
   340  func (o AuthorizerArrayOutput) ToAuthorizerArrayOutputWithContext(ctx context.Context) AuthorizerArrayOutput {
   341  	return o
   342  }
   343  
   344  func (o AuthorizerArrayOutput) Index(i pulumi.IntInput) AuthorizerOutput {
   345  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Authorizer {
   346  		return vs[0].([]*Authorizer)[vs[1].(int)]
   347  	}).(AuthorizerOutput)
   348  }
   349  
   350  type AuthorizerMapOutput struct{ *pulumi.OutputState }
   351  
   352  func (AuthorizerMapOutput) ElementType() reflect.Type {
   353  	return reflect.TypeOf((*map[string]*Authorizer)(nil)).Elem()
   354  }
   355  
   356  func (o AuthorizerMapOutput) ToAuthorizerMapOutput() AuthorizerMapOutput {
   357  	return o
   358  }
   359  
   360  func (o AuthorizerMapOutput) ToAuthorizerMapOutputWithContext(ctx context.Context) AuthorizerMapOutput {
   361  	return o
   362  }
   363  
   364  func (o AuthorizerMapOutput) MapIndex(k pulumi.StringInput) AuthorizerOutput {
   365  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Authorizer {
   366  		return vs[0].(map[string]*Authorizer)[vs[1].(string)]
   367  	}).(AuthorizerOutput)
   368  }
   369  
   370  func init() {
   371  	pulumi.RegisterInputType(reflect.TypeOf((*AuthorizerInput)(nil)).Elem(), &Authorizer{})
   372  	pulumi.RegisterInputType(reflect.TypeOf((*AuthorizerArrayInput)(nil)).Elem(), AuthorizerArray{})
   373  	pulumi.RegisterInputType(reflect.TypeOf((*AuthorizerMapInput)(nil)).Elem(), AuthorizerMap{})
   374  	pulumi.RegisterOutputType(AuthorizerOutput{})
   375  	pulumi.RegisterOutputType(AuthorizerArrayOutput{})
   376  	pulumi.RegisterOutputType(AuthorizerMapOutput{})
   377  }