github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/apigateway/usagePlanKey.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  	"errors"
    11  	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
    12  	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    13  )
    14  
    15  // Provides an API Gateway Usage Plan Key.
    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/apigateway"
    26  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    27  //
    28  // )
    29  //
    30  //	func main() {
    31  //		pulumi.Run(func(ctx *pulumi.Context) error {
    32  //			test, err := apigateway.NewRestApi(ctx, "test", &apigateway.RestApiArgs{
    33  //				Name: pulumi.String("MyDemoAPI"),
    34  //			})
    35  //			if err != nil {
    36  //				return err
    37  //			}
    38  //			// ...
    39  //			myusageplan, err := apigateway.NewUsagePlan(ctx, "myusageplan", &apigateway.UsagePlanArgs{
    40  //				Name: pulumi.String("my_usage_plan"),
    41  //				ApiStages: apigateway.UsagePlanApiStageArray{
    42  //					&apigateway.UsagePlanApiStageArgs{
    43  //						ApiId: test.ID(),
    44  //						Stage: pulumi.Any(foo.StageName),
    45  //					},
    46  //				},
    47  //			})
    48  //			if err != nil {
    49  //				return err
    50  //			}
    51  //			mykey, err := apigateway.NewApiKey(ctx, "mykey", &apigateway.ApiKeyArgs{
    52  //				Name: pulumi.String("my_key"),
    53  //			})
    54  //			if err != nil {
    55  //				return err
    56  //			}
    57  //			_, err = apigateway.NewUsagePlanKey(ctx, "main", &apigateway.UsagePlanKeyArgs{
    58  //				KeyId:       mykey.ID(),
    59  //				KeyType:     pulumi.String("API_KEY"),
    60  //				UsagePlanId: myusageplan.ID(),
    61  //			})
    62  //			if err != nil {
    63  //				return err
    64  //			}
    65  //			return nil
    66  //		})
    67  //	}
    68  //
    69  // ```
    70  // <!--End PulumiCodeChooser -->
    71  //
    72  // ## Import
    73  //
    74  // Using `pulumi import`, import AWS API Gateway Usage Plan Key using the `USAGE-PLAN-ID/USAGE-PLAN-KEY-ID`. For example:
    75  //
    76  // ```sh
    77  // $ pulumi import aws:apigateway/usagePlanKey:UsagePlanKey key 12345abcde/zzz
    78  // ```
    79  type UsagePlanKey struct {
    80  	pulumi.CustomResourceState
    81  
    82  	// Identifier of the API key resource.
    83  	KeyId pulumi.StringOutput `pulumi:"keyId"`
    84  	// Type of the API key resource. Currently, the valid key type is API_KEY.
    85  	KeyType pulumi.StringOutput `pulumi:"keyType"`
    86  	// Name of a usage plan key.
    87  	Name pulumi.StringOutput `pulumi:"name"`
    88  	// Id of the usage plan resource representing to associate the key to.
    89  	UsagePlanId pulumi.StringOutput `pulumi:"usagePlanId"`
    90  	// Value of a usage plan key.
    91  	Value pulumi.StringOutput `pulumi:"value"`
    92  }
    93  
    94  // NewUsagePlanKey registers a new resource with the given unique name, arguments, and options.
    95  func NewUsagePlanKey(ctx *pulumi.Context,
    96  	name string, args *UsagePlanKeyArgs, opts ...pulumi.ResourceOption) (*UsagePlanKey, error) {
    97  	if args == nil {
    98  		return nil, errors.New("missing one or more required arguments")
    99  	}
   100  
   101  	if args.KeyId == nil {
   102  		return nil, errors.New("invalid value for required argument 'KeyId'")
   103  	}
   104  	if args.KeyType == nil {
   105  		return nil, errors.New("invalid value for required argument 'KeyType'")
   106  	}
   107  	if args.UsagePlanId == nil {
   108  		return nil, errors.New("invalid value for required argument 'UsagePlanId'")
   109  	}
   110  	opts = internal.PkgResourceDefaultOpts(opts)
   111  	var resource UsagePlanKey
   112  	err := ctx.RegisterResource("aws:apigateway/usagePlanKey:UsagePlanKey", name, args, &resource, opts...)
   113  	if err != nil {
   114  		return nil, err
   115  	}
   116  	return &resource, nil
   117  }
   118  
   119  // GetUsagePlanKey gets an existing UsagePlanKey resource's state with the given name, ID, and optional
   120  // state properties that are used to uniquely qualify the lookup (nil if not required).
   121  func GetUsagePlanKey(ctx *pulumi.Context,
   122  	name string, id pulumi.IDInput, state *UsagePlanKeyState, opts ...pulumi.ResourceOption) (*UsagePlanKey, error) {
   123  	var resource UsagePlanKey
   124  	err := ctx.ReadResource("aws:apigateway/usagePlanKey:UsagePlanKey", name, id, state, &resource, opts...)
   125  	if err != nil {
   126  		return nil, err
   127  	}
   128  	return &resource, nil
   129  }
   130  
   131  // Input properties used for looking up and filtering UsagePlanKey resources.
   132  type usagePlanKeyState struct {
   133  	// Identifier of the API key resource.
   134  	KeyId *string `pulumi:"keyId"`
   135  	// Type of the API key resource. Currently, the valid key type is API_KEY.
   136  	KeyType *string `pulumi:"keyType"`
   137  	// Name of a usage plan key.
   138  	Name *string `pulumi:"name"`
   139  	// Id of the usage plan resource representing to associate the key to.
   140  	UsagePlanId *string `pulumi:"usagePlanId"`
   141  	// Value of a usage plan key.
   142  	Value *string `pulumi:"value"`
   143  }
   144  
   145  type UsagePlanKeyState struct {
   146  	// Identifier of the API key resource.
   147  	KeyId pulumi.StringPtrInput
   148  	// Type of the API key resource. Currently, the valid key type is API_KEY.
   149  	KeyType pulumi.StringPtrInput
   150  	// Name of a usage plan key.
   151  	Name pulumi.StringPtrInput
   152  	// Id of the usage plan resource representing to associate the key to.
   153  	UsagePlanId pulumi.StringPtrInput
   154  	// Value of a usage plan key.
   155  	Value pulumi.StringPtrInput
   156  }
   157  
   158  func (UsagePlanKeyState) ElementType() reflect.Type {
   159  	return reflect.TypeOf((*usagePlanKeyState)(nil)).Elem()
   160  }
   161  
   162  type usagePlanKeyArgs struct {
   163  	// Identifier of the API key resource.
   164  	KeyId string `pulumi:"keyId"`
   165  	// Type of the API key resource. Currently, the valid key type is API_KEY.
   166  	KeyType string `pulumi:"keyType"`
   167  	// Id of the usage plan resource representing to associate the key to.
   168  	UsagePlanId string `pulumi:"usagePlanId"`
   169  }
   170  
   171  // The set of arguments for constructing a UsagePlanKey resource.
   172  type UsagePlanKeyArgs struct {
   173  	// Identifier of the API key resource.
   174  	KeyId pulumi.StringInput
   175  	// Type of the API key resource. Currently, the valid key type is API_KEY.
   176  	KeyType pulumi.StringInput
   177  	// Id of the usage plan resource representing to associate the key to.
   178  	UsagePlanId pulumi.StringInput
   179  }
   180  
   181  func (UsagePlanKeyArgs) ElementType() reflect.Type {
   182  	return reflect.TypeOf((*usagePlanKeyArgs)(nil)).Elem()
   183  }
   184  
   185  type UsagePlanKeyInput interface {
   186  	pulumi.Input
   187  
   188  	ToUsagePlanKeyOutput() UsagePlanKeyOutput
   189  	ToUsagePlanKeyOutputWithContext(ctx context.Context) UsagePlanKeyOutput
   190  }
   191  
   192  func (*UsagePlanKey) ElementType() reflect.Type {
   193  	return reflect.TypeOf((**UsagePlanKey)(nil)).Elem()
   194  }
   195  
   196  func (i *UsagePlanKey) ToUsagePlanKeyOutput() UsagePlanKeyOutput {
   197  	return i.ToUsagePlanKeyOutputWithContext(context.Background())
   198  }
   199  
   200  func (i *UsagePlanKey) ToUsagePlanKeyOutputWithContext(ctx context.Context) UsagePlanKeyOutput {
   201  	return pulumi.ToOutputWithContext(ctx, i).(UsagePlanKeyOutput)
   202  }
   203  
   204  // UsagePlanKeyArrayInput is an input type that accepts UsagePlanKeyArray and UsagePlanKeyArrayOutput values.
   205  // You can construct a concrete instance of `UsagePlanKeyArrayInput` via:
   206  //
   207  //	UsagePlanKeyArray{ UsagePlanKeyArgs{...} }
   208  type UsagePlanKeyArrayInput interface {
   209  	pulumi.Input
   210  
   211  	ToUsagePlanKeyArrayOutput() UsagePlanKeyArrayOutput
   212  	ToUsagePlanKeyArrayOutputWithContext(context.Context) UsagePlanKeyArrayOutput
   213  }
   214  
   215  type UsagePlanKeyArray []UsagePlanKeyInput
   216  
   217  func (UsagePlanKeyArray) ElementType() reflect.Type {
   218  	return reflect.TypeOf((*[]*UsagePlanKey)(nil)).Elem()
   219  }
   220  
   221  func (i UsagePlanKeyArray) ToUsagePlanKeyArrayOutput() UsagePlanKeyArrayOutput {
   222  	return i.ToUsagePlanKeyArrayOutputWithContext(context.Background())
   223  }
   224  
   225  func (i UsagePlanKeyArray) ToUsagePlanKeyArrayOutputWithContext(ctx context.Context) UsagePlanKeyArrayOutput {
   226  	return pulumi.ToOutputWithContext(ctx, i).(UsagePlanKeyArrayOutput)
   227  }
   228  
   229  // UsagePlanKeyMapInput is an input type that accepts UsagePlanKeyMap and UsagePlanKeyMapOutput values.
   230  // You can construct a concrete instance of `UsagePlanKeyMapInput` via:
   231  //
   232  //	UsagePlanKeyMap{ "key": UsagePlanKeyArgs{...} }
   233  type UsagePlanKeyMapInput interface {
   234  	pulumi.Input
   235  
   236  	ToUsagePlanKeyMapOutput() UsagePlanKeyMapOutput
   237  	ToUsagePlanKeyMapOutputWithContext(context.Context) UsagePlanKeyMapOutput
   238  }
   239  
   240  type UsagePlanKeyMap map[string]UsagePlanKeyInput
   241  
   242  func (UsagePlanKeyMap) ElementType() reflect.Type {
   243  	return reflect.TypeOf((*map[string]*UsagePlanKey)(nil)).Elem()
   244  }
   245  
   246  func (i UsagePlanKeyMap) ToUsagePlanKeyMapOutput() UsagePlanKeyMapOutput {
   247  	return i.ToUsagePlanKeyMapOutputWithContext(context.Background())
   248  }
   249  
   250  func (i UsagePlanKeyMap) ToUsagePlanKeyMapOutputWithContext(ctx context.Context) UsagePlanKeyMapOutput {
   251  	return pulumi.ToOutputWithContext(ctx, i).(UsagePlanKeyMapOutput)
   252  }
   253  
   254  type UsagePlanKeyOutput struct{ *pulumi.OutputState }
   255  
   256  func (UsagePlanKeyOutput) ElementType() reflect.Type {
   257  	return reflect.TypeOf((**UsagePlanKey)(nil)).Elem()
   258  }
   259  
   260  func (o UsagePlanKeyOutput) ToUsagePlanKeyOutput() UsagePlanKeyOutput {
   261  	return o
   262  }
   263  
   264  func (o UsagePlanKeyOutput) ToUsagePlanKeyOutputWithContext(ctx context.Context) UsagePlanKeyOutput {
   265  	return o
   266  }
   267  
   268  // Identifier of the API key resource.
   269  func (o UsagePlanKeyOutput) KeyId() pulumi.StringOutput {
   270  	return o.ApplyT(func(v *UsagePlanKey) pulumi.StringOutput { return v.KeyId }).(pulumi.StringOutput)
   271  }
   272  
   273  // Type of the API key resource. Currently, the valid key type is API_KEY.
   274  func (o UsagePlanKeyOutput) KeyType() pulumi.StringOutput {
   275  	return o.ApplyT(func(v *UsagePlanKey) pulumi.StringOutput { return v.KeyType }).(pulumi.StringOutput)
   276  }
   277  
   278  // Name of a usage plan key.
   279  func (o UsagePlanKeyOutput) Name() pulumi.StringOutput {
   280  	return o.ApplyT(func(v *UsagePlanKey) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
   281  }
   282  
   283  // Id of the usage plan resource representing to associate the key to.
   284  func (o UsagePlanKeyOutput) UsagePlanId() pulumi.StringOutput {
   285  	return o.ApplyT(func(v *UsagePlanKey) pulumi.StringOutput { return v.UsagePlanId }).(pulumi.StringOutput)
   286  }
   287  
   288  // Value of a usage plan key.
   289  func (o UsagePlanKeyOutput) Value() pulumi.StringOutput {
   290  	return o.ApplyT(func(v *UsagePlanKey) pulumi.StringOutput { return v.Value }).(pulumi.StringOutput)
   291  }
   292  
   293  type UsagePlanKeyArrayOutput struct{ *pulumi.OutputState }
   294  
   295  func (UsagePlanKeyArrayOutput) ElementType() reflect.Type {
   296  	return reflect.TypeOf((*[]*UsagePlanKey)(nil)).Elem()
   297  }
   298  
   299  func (o UsagePlanKeyArrayOutput) ToUsagePlanKeyArrayOutput() UsagePlanKeyArrayOutput {
   300  	return o
   301  }
   302  
   303  func (o UsagePlanKeyArrayOutput) ToUsagePlanKeyArrayOutputWithContext(ctx context.Context) UsagePlanKeyArrayOutput {
   304  	return o
   305  }
   306  
   307  func (o UsagePlanKeyArrayOutput) Index(i pulumi.IntInput) UsagePlanKeyOutput {
   308  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *UsagePlanKey {
   309  		return vs[0].([]*UsagePlanKey)[vs[1].(int)]
   310  	}).(UsagePlanKeyOutput)
   311  }
   312  
   313  type UsagePlanKeyMapOutput struct{ *pulumi.OutputState }
   314  
   315  func (UsagePlanKeyMapOutput) ElementType() reflect.Type {
   316  	return reflect.TypeOf((*map[string]*UsagePlanKey)(nil)).Elem()
   317  }
   318  
   319  func (o UsagePlanKeyMapOutput) ToUsagePlanKeyMapOutput() UsagePlanKeyMapOutput {
   320  	return o
   321  }
   322  
   323  func (o UsagePlanKeyMapOutput) ToUsagePlanKeyMapOutputWithContext(ctx context.Context) UsagePlanKeyMapOutput {
   324  	return o
   325  }
   326  
   327  func (o UsagePlanKeyMapOutput) MapIndex(k pulumi.StringInput) UsagePlanKeyOutput {
   328  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *UsagePlanKey {
   329  		return vs[0].(map[string]*UsagePlanKey)[vs[1].(string)]
   330  	}).(UsagePlanKeyOutput)
   331  }
   332  
   333  func init() {
   334  	pulumi.RegisterInputType(reflect.TypeOf((*UsagePlanKeyInput)(nil)).Elem(), &UsagePlanKey{})
   335  	pulumi.RegisterInputType(reflect.TypeOf((*UsagePlanKeyArrayInput)(nil)).Elem(), UsagePlanKeyArray{})
   336  	pulumi.RegisterInputType(reflect.TypeOf((*UsagePlanKeyMapInput)(nil)).Elem(), UsagePlanKeyMap{})
   337  	pulumi.RegisterOutputType(UsagePlanKeyOutput{})
   338  	pulumi.RegisterOutputType(UsagePlanKeyArrayOutput{})
   339  	pulumi.RegisterOutputType(UsagePlanKeyMapOutput{})
   340  }