github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/apigateway/apiKey.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 apigateway
     5  
     6  import (
     7  	"context"
     8  	"reflect"
     9  
    10  	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
    11  	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    12  )
    13  
    14  // Provides an API Gateway API Key.
    15  //
    16  // > **NOTE:** Since the API Gateway usage plans feature was launched on August 11, 2016, usage plans are now **required** to associate an API key with an API stage.
    17  //
    18  // ## Example Usage
    19  //
    20  // <!--Start PulumiCodeChooser -->
    21  // ```go
    22  // package main
    23  //
    24  // import (
    25  //
    26  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/apigateway"
    27  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    28  //
    29  // )
    30  //
    31  //	func main() {
    32  //		pulumi.Run(func(ctx *pulumi.Context) error {
    33  //			_, err := apigateway.NewApiKey(ctx, "example", &apigateway.ApiKeyArgs{
    34  //				Name: pulumi.String("example"),
    35  //			})
    36  //			if err != nil {
    37  //				return err
    38  //			}
    39  //			return nil
    40  //		})
    41  //	}
    42  //
    43  // ```
    44  // <!--End PulumiCodeChooser -->
    45  //
    46  // ## Import
    47  //
    48  // Using `pulumi import`, import API Gateway Keys using the `id`. For example:
    49  //
    50  // ```sh
    51  // $ pulumi import aws:apigateway/apiKey:ApiKey example 8bklk8bl1k3sB38D9B3l0enyWT8c09B30lkq0blk
    52  // ```
    53  type ApiKey struct {
    54  	pulumi.CustomResourceState
    55  
    56  	// ARN
    57  	Arn pulumi.StringOutput `pulumi:"arn"`
    58  	// Creation date of the API key
    59  	CreatedDate pulumi.StringOutput `pulumi:"createdDate"`
    60  	// An Amazon Web Services Marketplace customer identifier, when integrating with the Amazon Web Services SaaS Marketplace.
    61  	CustomerId pulumi.StringPtrOutput `pulumi:"customerId"`
    62  	// API key description. Defaults to "Managed by Pulumi".
    63  	Description pulumi.StringOutput `pulumi:"description"`
    64  	// Whether the API key can be used by callers. Defaults to `true`.
    65  	Enabled pulumi.BoolPtrOutput `pulumi:"enabled"`
    66  	// Last update date of the API key
    67  	LastUpdatedDate pulumi.StringOutput `pulumi:"lastUpdatedDate"`
    68  	// Name of the API key.
    69  	Name pulumi.StringOutput `pulumi:"name"`
    70  	// Key-value map of resource tags. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
    71  	Tags pulumi.StringMapOutput `pulumi:"tags"`
    72  	// Map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
    73  	//
    74  	// Deprecated: Please use `tags` instead.
    75  	TagsAll pulumi.StringMapOutput `pulumi:"tagsAll"`
    76  	// Value of the API key. If specified, the value must be an alphanumeric string between 20 and 128 characters. If not specified, it will be automatically generated by AWS on creation.
    77  	Value pulumi.StringOutput `pulumi:"value"`
    78  }
    79  
    80  // NewApiKey registers a new resource with the given unique name, arguments, and options.
    81  func NewApiKey(ctx *pulumi.Context,
    82  	name string, args *ApiKeyArgs, opts ...pulumi.ResourceOption) (*ApiKey, error) {
    83  	if args == nil {
    84  		args = &ApiKeyArgs{}
    85  	}
    86  
    87  	if args.Description == nil {
    88  		args.Description = pulumi.StringPtr("Managed by Pulumi")
    89  	}
    90  	if args.Value != nil {
    91  		args.Value = pulumi.ToSecret(args.Value).(pulumi.StringPtrInput)
    92  	}
    93  	secrets := pulumi.AdditionalSecretOutputs([]string{
    94  		"value",
    95  	})
    96  	opts = append(opts, secrets)
    97  	opts = internal.PkgResourceDefaultOpts(opts)
    98  	var resource ApiKey
    99  	err := ctx.RegisterResource("aws:apigateway/apiKey:ApiKey", name, args, &resource, opts...)
   100  	if err != nil {
   101  		return nil, err
   102  	}
   103  	return &resource, nil
   104  }
   105  
   106  // GetApiKey gets an existing ApiKey resource's state with the given name, ID, and optional
   107  // state properties that are used to uniquely qualify the lookup (nil if not required).
   108  func GetApiKey(ctx *pulumi.Context,
   109  	name string, id pulumi.IDInput, state *ApiKeyState, opts ...pulumi.ResourceOption) (*ApiKey, error) {
   110  	var resource ApiKey
   111  	err := ctx.ReadResource("aws:apigateway/apiKey:ApiKey", name, id, state, &resource, opts...)
   112  	if err != nil {
   113  		return nil, err
   114  	}
   115  	return &resource, nil
   116  }
   117  
   118  // Input properties used for looking up and filtering ApiKey resources.
   119  type apiKeyState struct {
   120  	// ARN
   121  	Arn *string `pulumi:"arn"`
   122  	// Creation date of the API key
   123  	CreatedDate *string `pulumi:"createdDate"`
   124  	// An Amazon Web Services Marketplace customer identifier, when integrating with the Amazon Web Services SaaS Marketplace.
   125  	CustomerId *string `pulumi:"customerId"`
   126  	// API key description. Defaults to "Managed by Pulumi".
   127  	Description *string `pulumi:"description"`
   128  	// Whether the API key can be used by callers. Defaults to `true`.
   129  	Enabled *bool `pulumi:"enabled"`
   130  	// Last update date of the API key
   131  	LastUpdatedDate *string `pulumi:"lastUpdatedDate"`
   132  	// Name of the API key.
   133  	Name *string `pulumi:"name"`
   134  	// Key-value map of resource tags. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   135  	Tags map[string]string `pulumi:"tags"`
   136  	// Map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   137  	//
   138  	// Deprecated: Please use `tags` instead.
   139  	TagsAll map[string]string `pulumi:"tagsAll"`
   140  	// Value of the API key. If specified, the value must be an alphanumeric string between 20 and 128 characters. If not specified, it will be automatically generated by AWS on creation.
   141  	Value *string `pulumi:"value"`
   142  }
   143  
   144  type ApiKeyState struct {
   145  	// ARN
   146  	Arn pulumi.StringPtrInput
   147  	// Creation date of the API key
   148  	CreatedDate pulumi.StringPtrInput
   149  	// An Amazon Web Services Marketplace customer identifier, when integrating with the Amazon Web Services SaaS Marketplace.
   150  	CustomerId pulumi.StringPtrInput
   151  	// API key description. Defaults to "Managed by Pulumi".
   152  	Description pulumi.StringPtrInput
   153  	// Whether the API key can be used by callers. Defaults to `true`.
   154  	Enabled pulumi.BoolPtrInput
   155  	// Last update date of the API key
   156  	LastUpdatedDate pulumi.StringPtrInput
   157  	// Name of the API key.
   158  	Name pulumi.StringPtrInput
   159  	// Key-value map of resource tags. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   160  	Tags pulumi.StringMapInput
   161  	// Map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   162  	//
   163  	// Deprecated: Please use `tags` instead.
   164  	TagsAll pulumi.StringMapInput
   165  	// Value of the API key. If specified, the value must be an alphanumeric string between 20 and 128 characters. If not specified, it will be automatically generated by AWS on creation.
   166  	Value pulumi.StringPtrInput
   167  }
   168  
   169  func (ApiKeyState) ElementType() reflect.Type {
   170  	return reflect.TypeOf((*apiKeyState)(nil)).Elem()
   171  }
   172  
   173  type apiKeyArgs struct {
   174  	// An Amazon Web Services Marketplace customer identifier, when integrating with the Amazon Web Services SaaS Marketplace.
   175  	CustomerId *string `pulumi:"customerId"`
   176  	// API key description. Defaults to "Managed by Pulumi".
   177  	Description *string `pulumi:"description"`
   178  	// Whether the API key can be used by callers. Defaults to `true`.
   179  	Enabled *bool `pulumi:"enabled"`
   180  	// Name of the API key.
   181  	Name *string `pulumi:"name"`
   182  	// Key-value map of resource tags. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   183  	Tags map[string]string `pulumi:"tags"`
   184  	// Value of the API key. If specified, the value must be an alphanumeric string between 20 and 128 characters. If not specified, it will be automatically generated by AWS on creation.
   185  	Value *string `pulumi:"value"`
   186  }
   187  
   188  // The set of arguments for constructing a ApiKey resource.
   189  type ApiKeyArgs struct {
   190  	// An Amazon Web Services Marketplace customer identifier, when integrating with the Amazon Web Services SaaS Marketplace.
   191  	CustomerId pulumi.StringPtrInput
   192  	// API key description. Defaults to "Managed by Pulumi".
   193  	Description pulumi.StringPtrInput
   194  	// Whether the API key can be used by callers. Defaults to `true`.
   195  	Enabled pulumi.BoolPtrInput
   196  	// Name of the API key.
   197  	Name pulumi.StringPtrInput
   198  	// Key-value map of resource tags. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   199  	Tags pulumi.StringMapInput
   200  	// Value of the API key. If specified, the value must be an alphanumeric string between 20 and 128 characters. If not specified, it will be automatically generated by AWS on creation.
   201  	Value pulumi.StringPtrInput
   202  }
   203  
   204  func (ApiKeyArgs) ElementType() reflect.Type {
   205  	return reflect.TypeOf((*apiKeyArgs)(nil)).Elem()
   206  }
   207  
   208  type ApiKeyInput interface {
   209  	pulumi.Input
   210  
   211  	ToApiKeyOutput() ApiKeyOutput
   212  	ToApiKeyOutputWithContext(ctx context.Context) ApiKeyOutput
   213  }
   214  
   215  func (*ApiKey) ElementType() reflect.Type {
   216  	return reflect.TypeOf((**ApiKey)(nil)).Elem()
   217  }
   218  
   219  func (i *ApiKey) ToApiKeyOutput() ApiKeyOutput {
   220  	return i.ToApiKeyOutputWithContext(context.Background())
   221  }
   222  
   223  func (i *ApiKey) ToApiKeyOutputWithContext(ctx context.Context) ApiKeyOutput {
   224  	return pulumi.ToOutputWithContext(ctx, i).(ApiKeyOutput)
   225  }
   226  
   227  // ApiKeyArrayInput is an input type that accepts ApiKeyArray and ApiKeyArrayOutput values.
   228  // You can construct a concrete instance of `ApiKeyArrayInput` via:
   229  //
   230  //	ApiKeyArray{ ApiKeyArgs{...} }
   231  type ApiKeyArrayInput interface {
   232  	pulumi.Input
   233  
   234  	ToApiKeyArrayOutput() ApiKeyArrayOutput
   235  	ToApiKeyArrayOutputWithContext(context.Context) ApiKeyArrayOutput
   236  }
   237  
   238  type ApiKeyArray []ApiKeyInput
   239  
   240  func (ApiKeyArray) ElementType() reflect.Type {
   241  	return reflect.TypeOf((*[]*ApiKey)(nil)).Elem()
   242  }
   243  
   244  func (i ApiKeyArray) ToApiKeyArrayOutput() ApiKeyArrayOutput {
   245  	return i.ToApiKeyArrayOutputWithContext(context.Background())
   246  }
   247  
   248  func (i ApiKeyArray) ToApiKeyArrayOutputWithContext(ctx context.Context) ApiKeyArrayOutput {
   249  	return pulumi.ToOutputWithContext(ctx, i).(ApiKeyArrayOutput)
   250  }
   251  
   252  // ApiKeyMapInput is an input type that accepts ApiKeyMap and ApiKeyMapOutput values.
   253  // You can construct a concrete instance of `ApiKeyMapInput` via:
   254  //
   255  //	ApiKeyMap{ "key": ApiKeyArgs{...} }
   256  type ApiKeyMapInput interface {
   257  	pulumi.Input
   258  
   259  	ToApiKeyMapOutput() ApiKeyMapOutput
   260  	ToApiKeyMapOutputWithContext(context.Context) ApiKeyMapOutput
   261  }
   262  
   263  type ApiKeyMap map[string]ApiKeyInput
   264  
   265  func (ApiKeyMap) ElementType() reflect.Type {
   266  	return reflect.TypeOf((*map[string]*ApiKey)(nil)).Elem()
   267  }
   268  
   269  func (i ApiKeyMap) ToApiKeyMapOutput() ApiKeyMapOutput {
   270  	return i.ToApiKeyMapOutputWithContext(context.Background())
   271  }
   272  
   273  func (i ApiKeyMap) ToApiKeyMapOutputWithContext(ctx context.Context) ApiKeyMapOutput {
   274  	return pulumi.ToOutputWithContext(ctx, i).(ApiKeyMapOutput)
   275  }
   276  
   277  type ApiKeyOutput struct{ *pulumi.OutputState }
   278  
   279  func (ApiKeyOutput) ElementType() reflect.Type {
   280  	return reflect.TypeOf((**ApiKey)(nil)).Elem()
   281  }
   282  
   283  func (o ApiKeyOutput) ToApiKeyOutput() ApiKeyOutput {
   284  	return o
   285  }
   286  
   287  func (o ApiKeyOutput) ToApiKeyOutputWithContext(ctx context.Context) ApiKeyOutput {
   288  	return o
   289  }
   290  
   291  // ARN
   292  func (o ApiKeyOutput) Arn() pulumi.StringOutput {
   293  	return o.ApplyT(func(v *ApiKey) pulumi.StringOutput { return v.Arn }).(pulumi.StringOutput)
   294  }
   295  
   296  // Creation date of the API key
   297  func (o ApiKeyOutput) CreatedDate() pulumi.StringOutput {
   298  	return o.ApplyT(func(v *ApiKey) pulumi.StringOutput { return v.CreatedDate }).(pulumi.StringOutput)
   299  }
   300  
   301  // An Amazon Web Services Marketplace customer identifier, when integrating with the Amazon Web Services SaaS Marketplace.
   302  func (o ApiKeyOutput) CustomerId() pulumi.StringPtrOutput {
   303  	return o.ApplyT(func(v *ApiKey) pulumi.StringPtrOutput { return v.CustomerId }).(pulumi.StringPtrOutput)
   304  }
   305  
   306  // API key description. Defaults to "Managed by Pulumi".
   307  func (o ApiKeyOutput) Description() pulumi.StringOutput {
   308  	return o.ApplyT(func(v *ApiKey) pulumi.StringOutput { return v.Description }).(pulumi.StringOutput)
   309  }
   310  
   311  // Whether the API key can be used by callers. Defaults to `true`.
   312  func (o ApiKeyOutput) Enabled() pulumi.BoolPtrOutput {
   313  	return o.ApplyT(func(v *ApiKey) pulumi.BoolPtrOutput { return v.Enabled }).(pulumi.BoolPtrOutput)
   314  }
   315  
   316  // Last update date of the API key
   317  func (o ApiKeyOutput) LastUpdatedDate() pulumi.StringOutput {
   318  	return o.ApplyT(func(v *ApiKey) pulumi.StringOutput { return v.LastUpdatedDate }).(pulumi.StringOutput)
   319  }
   320  
   321  // Name of the API key.
   322  func (o ApiKeyOutput) Name() pulumi.StringOutput {
   323  	return o.ApplyT(func(v *ApiKey) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
   324  }
   325  
   326  // Key-value map of resource tags. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
   327  func (o ApiKeyOutput) Tags() pulumi.StringMapOutput {
   328  	return o.ApplyT(func(v *ApiKey) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)
   329  }
   330  
   331  // Map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
   332  //
   333  // Deprecated: Please use `tags` instead.
   334  func (o ApiKeyOutput) TagsAll() pulumi.StringMapOutput {
   335  	return o.ApplyT(func(v *ApiKey) pulumi.StringMapOutput { return v.TagsAll }).(pulumi.StringMapOutput)
   336  }
   337  
   338  // Value of the API key. If specified, the value must be an alphanumeric string between 20 and 128 characters. If not specified, it will be automatically generated by AWS on creation.
   339  func (o ApiKeyOutput) Value() pulumi.StringOutput {
   340  	return o.ApplyT(func(v *ApiKey) pulumi.StringOutput { return v.Value }).(pulumi.StringOutput)
   341  }
   342  
   343  type ApiKeyArrayOutput struct{ *pulumi.OutputState }
   344  
   345  func (ApiKeyArrayOutput) ElementType() reflect.Type {
   346  	return reflect.TypeOf((*[]*ApiKey)(nil)).Elem()
   347  }
   348  
   349  func (o ApiKeyArrayOutput) ToApiKeyArrayOutput() ApiKeyArrayOutput {
   350  	return o
   351  }
   352  
   353  func (o ApiKeyArrayOutput) ToApiKeyArrayOutputWithContext(ctx context.Context) ApiKeyArrayOutput {
   354  	return o
   355  }
   356  
   357  func (o ApiKeyArrayOutput) Index(i pulumi.IntInput) ApiKeyOutput {
   358  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *ApiKey {
   359  		return vs[0].([]*ApiKey)[vs[1].(int)]
   360  	}).(ApiKeyOutput)
   361  }
   362  
   363  type ApiKeyMapOutput struct{ *pulumi.OutputState }
   364  
   365  func (ApiKeyMapOutput) ElementType() reflect.Type {
   366  	return reflect.TypeOf((*map[string]*ApiKey)(nil)).Elem()
   367  }
   368  
   369  func (o ApiKeyMapOutput) ToApiKeyMapOutput() ApiKeyMapOutput {
   370  	return o
   371  }
   372  
   373  func (o ApiKeyMapOutput) ToApiKeyMapOutputWithContext(ctx context.Context) ApiKeyMapOutput {
   374  	return o
   375  }
   376  
   377  func (o ApiKeyMapOutput) MapIndex(k pulumi.StringInput) ApiKeyOutput {
   378  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *ApiKey {
   379  		return vs[0].(map[string]*ApiKey)[vs[1].(string)]
   380  	}).(ApiKeyOutput)
   381  }
   382  
   383  func init() {
   384  	pulumi.RegisterInputType(reflect.TypeOf((*ApiKeyInput)(nil)).Elem(), &ApiKey{})
   385  	pulumi.RegisterInputType(reflect.TypeOf((*ApiKeyArrayInput)(nil)).Elem(), ApiKeyArray{})
   386  	pulumi.RegisterInputType(reflect.TypeOf((*ApiKeyMapInput)(nil)).Elem(), ApiKeyMap{})
   387  	pulumi.RegisterOutputType(ApiKeyOutput{})
   388  	pulumi.RegisterOutputType(ApiKeyArrayOutput{})
   389  	pulumi.RegisterOutputType(ApiKeyMapOutput{})
   390  }