github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/appsync/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 appsync
     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 AppSync API 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/appsync"
    26  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    27  //
    28  // )
    29  //
    30  //	func main() {
    31  //		pulumi.Run(func(ctx *pulumi.Context) error {
    32  //			example, err := appsync.NewGraphQLApi(ctx, "example", &appsync.GraphQLApiArgs{
    33  //				AuthenticationType: pulumi.String("API_KEY"),
    34  //				Name:               pulumi.String("example"),
    35  //			})
    36  //			if err != nil {
    37  //				return err
    38  //			}
    39  //			_, err = appsync.NewApiKey(ctx, "example", &appsync.ApiKeyArgs{
    40  //				ApiId:   example.ID(),
    41  //				Expires: pulumi.String("2018-05-03T04:00:00Z"),
    42  //			})
    43  //			if err != nil {
    44  //				return err
    45  //			}
    46  //			return nil
    47  //		})
    48  //	}
    49  //
    50  // ```
    51  // <!--End PulumiCodeChooser -->
    52  //
    53  // ## Import
    54  //
    55  // Using `pulumi import`, import `aws_appsync_api_key` using the AppSync API ID and key separated by `:`. For example:
    56  //
    57  // ```sh
    58  // $ pulumi import aws:appsync/apiKey:ApiKey example xxxxx:yyyyy
    59  // ```
    60  type ApiKey struct {
    61  	pulumi.CustomResourceState
    62  
    63  	// ID of the associated AppSync API
    64  	ApiId pulumi.StringOutput `pulumi:"apiId"`
    65  	// API key description. Defaults to "Managed by Pulumi".
    66  	Description pulumi.StringOutput `pulumi:"description"`
    67  	// RFC3339 string representation of the expiry date. Rounded down to nearest hour. By default, it is 7 days from the date of creation.
    68  	Expires pulumi.StringPtrOutput `pulumi:"expires"`
    69  	// API key
    70  	Key pulumi.StringOutput `pulumi:"key"`
    71  }
    72  
    73  // NewApiKey registers a new resource with the given unique name, arguments, and options.
    74  func NewApiKey(ctx *pulumi.Context,
    75  	name string, args *ApiKeyArgs, opts ...pulumi.ResourceOption) (*ApiKey, error) {
    76  	if args == nil {
    77  		return nil, errors.New("missing one or more required arguments")
    78  	}
    79  
    80  	if args.ApiId == nil {
    81  		return nil, errors.New("invalid value for required argument 'ApiId'")
    82  	}
    83  	if args.Description == nil {
    84  		args.Description = pulumi.StringPtr("Managed by Pulumi")
    85  	}
    86  	secrets := pulumi.AdditionalSecretOutputs([]string{
    87  		"key",
    88  	})
    89  	opts = append(opts, secrets)
    90  	opts = internal.PkgResourceDefaultOpts(opts)
    91  	var resource ApiKey
    92  	err := ctx.RegisterResource("aws:appsync/apiKey:ApiKey", name, args, &resource, opts...)
    93  	if err != nil {
    94  		return nil, err
    95  	}
    96  	return &resource, nil
    97  }
    98  
    99  // GetApiKey gets an existing ApiKey resource's state with the given name, ID, and optional
   100  // state properties that are used to uniquely qualify the lookup (nil if not required).
   101  func GetApiKey(ctx *pulumi.Context,
   102  	name string, id pulumi.IDInput, state *ApiKeyState, opts ...pulumi.ResourceOption) (*ApiKey, error) {
   103  	var resource ApiKey
   104  	err := ctx.ReadResource("aws:appsync/apiKey:ApiKey", name, id, state, &resource, opts...)
   105  	if err != nil {
   106  		return nil, err
   107  	}
   108  	return &resource, nil
   109  }
   110  
   111  // Input properties used for looking up and filtering ApiKey resources.
   112  type apiKeyState struct {
   113  	// ID of the associated AppSync API
   114  	ApiId *string `pulumi:"apiId"`
   115  	// API key description. Defaults to "Managed by Pulumi".
   116  	Description *string `pulumi:"description"`
   117  	// RFC3339 string representation of the expiry date. Rounded down to nearest hour. By default, it is 7 days from the date of creation.
   118  	Expires *string `pulumi:"expires"`
   119  	// API key
   120  	Key *string `pulumi:"key"`
   121  }
   122  
   123  type ApiKeyState struct {
   124  	// ID of the associated AppSync API
   125  	ApiId pulumi.StringPtrInput
   126  	// API key description. Defaults to "Managed by Pulumi".
   127  	Description pulumi.StringPtrInput
   128  	// RFC3339 string representation of the expiry date. Rounded down to nearest hour. By default, it is 7 days from the date of creation.
   129  	Expires pulumi.StringPtrInput
   130  	// API key
   131  	Key pulumi.StringPtrInput
   132  }
   133  
   134  func (ApiKeyState) ElementType() reflect.Type {
   135  	return reflect.TypeOf((*apiKeyState)(nil)).Elem()
   136  }
   137  
   138  type apiKeyArgs struct {
   139  	// ID of the associated AppSync API
   140  	ApiId string `pulumi:"apiId"`
   141  	// API key description. Defaults to "Managed by Pulumi".
   142  	Description *string `pulumi:"description"`
   143  	// RFC3339 string representation of the expiry date. Rounded down to nearest hour. By default, it is 7 days from the date of creation.
   144  	Expires *string `pulumi:"expires"`
   145  }
   146  
   147  // The set of arguments for constructing a ApiKey resource.
   148  type ApiKeyArgs struct {
   149  	// ID of the associated AppSync API
   150  	ApiId pulumi.StringInput
   151  	// API key description. Defaults to "Managed by Pulumi".
   152  	Description pulumi.StringPtrInput
   153  	// RFC3339 string representation of the expiry date. Rounded down to nearest hour. By default, it is 7 days from the date of creation.
   154  	Expires pulumi.StringPtrInput
   155  }
   156  
   157  func (ApiKeyArgs) ElementType() reflect.Type {
   158  	return reflect.TypeOf((*apiKeyArgs)(nil)).Elem()
   159  }
   160  
   161  type ApiKeyInput interface {
   162  	pulumi.Input
   163  
   164  	ToApiKeyOutput() ApiKeyOutput
   165  	ToApiKeyOutputWithContext(ctx context.Context) ApiKeyOutput
   166  }
   167  
   168  func (*ApiKey) ElementType() reflect.Type {
   169  	return reflect.TypeOf((**ApiKey)(nil)).Elem()
   170  }
   171  
   172  func (i *ApiKey) ToApiKeyOutput() ApiKeyOutput {
   173  	return i.ToApiKeyOutputWithContext(context.Background())
   174  }
   175  
   176  func (i *ApiKey) ToApiKeyOutputWithContext(ctx context.Context) ApiKeyOutput {
   177  	return pulumi.ToOutputWithContext(ctx, i).(ApiKeyOutput)
   178  }
   179  
   180  // ApiKeyArrayInput is an input type that accepts ApiKeyArray and ApiKeyArrayOutput values.
   181  // You can construct a concrete instance of `ApiKeyArrayInput` via:
   182  //
   183  //	ApiKeyArray{ ApiKeyArgs{...} }
   184  type ApiKeyArrayInput interface {
   185  	pulumi.Input
   186  
   187  	ToApiKeyArrayOutput() ApiKeyArrayOutput
   188  	ToApiKeyArrayOutputWithContext(context.Context) ApiKeyArrayOutput
   189  }
   190  
   191  type ApiKeyArray []ApiKeyInput
   192  
   193  func (ApiKeyArray) ElementType() reflect.Type {
   194  	return reflect.TypeOf((*[]*ApiKey)(nil)).Elem()
   195  }
   196  
   197  func (i ApiKeyArray) ToApiKeyArrayOutput() ApiKeyArrayOutput {
   198  	return i.ToApiKeyArrayOutputWithContext(context.Background())
   199  }
   200  
   201  func (i ApiKeyArray) ToApiKeyArrayOutputWithContext(ctx context.Context) ApiKeyArrayOutput {
   202  	return pulumi.ToOutputWithContext(ctx, i).(ApiKeyArrayOutput)
   203  }
   204  
   205  // ApiKeyMapInput is an input type that accepts ApiKeyMap and ApiKeyMapOutput values.
   206  // You can construct a concrete instance of `ApiKeyMapInput` via:
   207  //
   208  //	ApiKeyMap{ "key": ApiKeyArgs{...} }
   209  type ApiKeyMapInput interface {
   210  	pulumi.Input
   211  
   212  	ToApiKeyMapOutput() ApiKeyMapOutput
   213  	ToApiKeyMapOutputWithContext(context.Context) ApiKeyMapOutput
   214  }
   215  
   216  type ApiKeyMap map[string]ApiKeyInput
   217  
   218  func (ApiKeyMap) ElementType() reflect.Type {
   219  	return reflect.TypeOf((*map[string]*ApiKey)(nil)).Elem()
   220  }
   221  
   222  func (i ApiKeyMap) ToApiKeyMapOutput() ApiKeyMapOutput {
   223  	return i.ToApiKeyMapOutputWithContext(context.Background())
   224  }
   225  
   226  func (i ApiKeyMap) ToApiKeyMapOutputWithContext(ctx context.Context) ApiKeyMapOutput {
   227  	return pulumi.ToOutputWithContext(ctx, i).(ApiKeyMapOutput)
   228  }
   229  
   230  type ApiKeyOutput struct{ *pulumi.OutputState }
   231  
   232  func (ApiKeyOutput) ElementType() reflect.Type {
   233  	return reflect.TypeOf((**ApiKey)(nil)).Elem()
   234  }
   235  
   236  func (o ApiKeyOutput) ToApiKeyOutput() ApiKeyOutput {
   237  	return o
   238  }
   239  
   240  func (o ApiKeyOutput) ToApiKeyOutputWithContext(ctx context.Context) ApiKeyOutput {
   241  	return o
   242  }
   243  
   244  // ID of the associated AppSync API
   245  func (o ApiKeyOutput) ApiId() pulumi.StringOutput {
   246  	return o.ApplyT(func(v *ApiKey) pulumi.StringOutput { return v.ApiId }).(pulumi.StringOutput)
   247  }
   248  
   249  // API key description. Defaults to "Managed by Pulumi".
   250  func (o ApiKeyOutput) Description() pulumi.StringOutput {
   251  	return o.ApplyT(func(v *ApiKey) pulumi.StringOutput { return v.Description }).(pulumi.StringOutput)
   252  }
   253  
   254  // RFC3339 string representation of the expiry date. Rounded down to nearest hour. By default, it is 7 days from the date of creation.
   255  func (o ApiKeyOutput) Expires() pulumi.StringPtrOutput {
   256  	return o.ApplyT(func(v *ApiKey) pulumi.StringPtrOutput { return v.Expires }).(pulumi.StringPtrOutput)
   257  }
   258  
   259  // API key
   260  func (o ApiKeyOutput) Key() pulumi.StringOutput {
   261  	return o.ApplyT(func(v *ApiKey) pulumi.StringOutput { return v.Key }).(pulumi.StringOutput)
   262  }
   263  
   264  type ApiKeyArrayOutput struct{ *pulumi.OutputState }
   265  
   266  func (ApiKeyArrayOutput) ElementType() reflect.Type {
   267  	return reflect.TypeOf((*[]*ApiKey)(nil)).Elem()
   268  }
   269  
   270  func (o ApiKeyArrayOutput) ToApiKeyArrayOutput() ApiKeyArrayOutput {
   271  	return o
   272  }
   273  
   274  func (o ApiKeyArrayOutput) ToApiKeyArrayOutputWithContext(ctx context.Context) ApiKeyArrayOutput {
   275  	return o
   276  }
   277  
   278  func (o ApiKeyArrayOutput) Index(i pulumi.IntInput) ApiKeyOutput {
   279  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *ApiKey {
   280  		return vs[0].([]*ApiKey)[vs[1].(int)]
   281  	}).(ApiKeyOutput)
   282  }
   283  
   284  type ApiKeyMapOutput struct{ *pulumi.OutputState }
   285  
   286  func (ApiKeyMapOutput) ElementType() reflect.Type {
   287  	return reflect.TypeOf((*map[string]*ApiKey)(nil)).Elem()
   288  }
   289  
   290  func (o ApiKeyMapOutput) ToApiKeyMapOutput() ApiKeyMapOutput {
   291  	return o
   292  }
   293  
   294  func (o ApiKeyMapOutput) ToApiKeyMapOutputWithContext(ctx context.Context) ApiKeyMapOutput {
   295  	return o
   296  }
   297  
   298  func (o ApiKeyMapOutput) MapIndex(k pulumi.StringInput) ApiKeyOutput {
   299  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *ApiKey {
   300  		return vs[0].(map[string]*ApiKey)[vs[1].(string)]
   301  	}).(ApiKeyOutput)
   302  }
   303  
   304  func init() {
   305  	pulumi.RegisterInputType(reflect.TypeOf((*ApiKeyInput)(nil)).Elem(), &ApiKey{})
   306  	pulumi.RegisterInputType(reflect.TypeOf((*ApiKeyArrayInput)(nil)).Elem(), ApiKeyArray{})
   307  	pulumi.RegisterInputType(reflect.TypeOf((*ApiKeyMapInput)(nil)).Elem(), ApiKeyMap{})
   308  	pulumi.RegisterOutputType(ApiKeyOutput{})
   309  	pulumi.RegisterOutputType(ApiKeyArrayOutput{})
   310  	pulumi.RegisterOutputType(ApiKeyMapOutput{})
   311  }