github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/athena/namedQuery.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 athena
     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 Athena Named Query resource.
    16  //
    17  // ## Example Usage
    18  //
    19  // <!--Start PulumiCodeChooser -->
    20  // ```go
    21  // package main
    22  //
    23  // import (
    24  //
    25  //	"fmt"
    26  //
    27  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/athena"
    28  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/kms"
    29  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3"
    30  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    31  //
    32  // )
    33  //
    34  //	func main() {
    35  //		pulumi.Run(func(ctx *pulumi.Context) error {
    36  //			hoge, err := s3.NewBucketV2(ctx, "hoge", &s3.BucketV2Args{
    37  //				Bucket: pulumi.String("tf-test"),
    38  //			})
    39  //			if err != nil {
    40  //				return err
    41  //			}
    42  //			test, err := kms.NewKey(ctx, "test", &kms.KeyArgs{
    43  //				DeletionWindowInDays: pulumi.Int(7),
    44  //				Description:          pulumi.String("Athena KMS Key"),
    45  //			})
    46  //			if err != nil {
    47  //				return err
    48  //			}
    49  //			testWorkgroup, err := athena.NewWorkgroup(ctx, "test", &athena.WorkgroupArgs{
    50  //				Name: pulumi.String("example"),
    51  //				Configuration: &athena.WorkgroupConfigurationArgs{
    52  //					ResultConfiguration: &athena.WorkgroupConfigurationResultConfigurationArgs{
    53  //						EncryptionConfiguration: &athena.WorkgroupConfigurationResultConfigurationEncryptionConfigurationArgs{
    54  //							EncryptionOption: pulumi.String("SSE_KMS"),
    55  //							KmsKeyArn:        test.Arn,
    56  //						},
    57  //					},
    58  //				},
    59  //			})
    60  //			if err != nil {
    61  //				return err
    62  //			}
    63  //			hogeDatabase, err := athena.NewDatabase(ctx, "hoge", &athena.DatabaseArgs{
    64  //				Name:   pulumi.String("users"),
    65  //				Bucket: hoge.ID(),
    66  //			})
    67  //			if err != nil {
    68  //				return err
    69  //			}
    70  //			_, err = athena.NewNamedQuery(ctx, "foo", &athena.NamedQueryArgs{
    71  //				Name:      pulumi.String("bar"),
    72  //				Workgroup: testWorkgroup.ID(),
    73  //				Database:  hogeDatabase.Name,
    74  //				Query: hogeDatabase.Name.ApplyT(func(name string) (string, error) {
    75  //					return fmt.Sprintf("SELECT * FROM %v limit 10;", name), nil
    76  //				}).(pulumi.StringOutput),
    77  //			})
    78  //			if err != nil {
    79  //				return err
    80  //			}
    81  //			return nil
    82  //		})
    83  //	}
    84  //
    85  // ```
    86  // <!--End PulumiCodeChooser -->
    87  //
    88  // ## Import
    89  //
    90  // Using `pulumi import`, import Athena Named Query using the query ID. For example:
    91  //
    92  // ```sh
    93  // $ pulumi import aws:athena/namedQuery:NamedQuery example 0123456789
    94  // ```
    95  type NamedQuery struct {
    96  	pulumi.CustomResourceState
    97  
    98  	// Database to which the query belongs.
    99  	Database pulumi.StringOutput `pulumi:"database"`
   100  	// Brief explanation of the query. Maximum length of 1024.
   101  	Description pulumi.StringPtrOutput `pulumi:"description"`
   102  	// Plain language name for the query. Maximum length of 128.
   103  	Name pulumi.StringOutput `pulumi:"name"`
   104  	// Text of the query itself. In other words, all query statements. Maximum length of 262144.
   105  	Query pulumi.StringOutput `pulumi:"query"`
   106  	// Workgroup to which the query belongs. Defaults to `primary`
   107  	Workgroup pulumi.StringPtrOutput `pulumi:"workgroup"`
   108  }
   109  
   110  // NewNamedQuery registers a new resource with the given unique name, arguments, and options.
   111  func NewNamedQuery(ctx *pulumi.Context,
   112  	name string, args *NamedQueryArgs, opts ...pulumi.ResourceOption) (*NamedQuery, error) {
   113  	if args == nil {
   114  		return nil, errors.New("missing one or more required arguments")
   115  	}
   116  
   117  	if args.Database == nil {
   118  		return nil, errors.New("invalid value for required argument 'Database'")
   119  	}
   120  	if args.Query == nil {
   121  		return nil, errors.New("invalid value for required argument 'Query'")
   122  	}
   123  	opts = internal.PkgResourceDefaultOpts(opts)
   124  	var resource NamedQuery
   125  	err := ctx.RegisterResource("aws:athena/namedQuery:NamedQuery", name, args, &resource, opts...)
   126  	if err != nil {
   127  		return nil, err
   128  	}
   129  	return &resource, nil
   130  }
   131  
   132  // GetNamedQuery gets an existing NamedQuery resource's state with the given name, ID, and optional
   133  // state properties that are used to uniquely qualify the lookup (nil if not required).
   134  func GetNamedQuery(ctx *pulumi.Context,
   135  	name string, id pulumi.IDInput, state *NamedQueryState, opts ...pulumi.ResourceOption) (*NamedQuery, error) {
   136  	var resource NamedQuery
   137  	err := ctx.ReadResource("aws:athena/namedQuery:NamedQuery", name, id, state, &resource, opts...)
   138  	if err != nil {
   139  		return nil, err
   140  	}
   141  	return &resource, nil
   142  }
   143  
   144  // Input properties used for looking up and filtering NamedQuery resources.
   145  type namedQueryState struct {
   146  	// Database to which the query belongs.
   147  	Database *string `pulumi:"database"`
   148  	// Brief explanation of the query. Maximum length of 1024.
   149  	Description *string `pulumi:"description"`
   150  	// Plain language name for the query. Maximum length of 128.
   151  	Name *string `pulumi:"name"`
   152  	// Text of the query itself. In other words, all query statements. Maximum length of 262144.
   153  	Query *string `pulumi:"query"`
   154  	// Workgroup to which the query belongs. Defaults to `primary`
   155  	Workgroup *string `pulumi:"workgroup"`
   156  }
   157  
   158  type NamedQueryState struct {
   159  	// Database to which the query belongs.
   160  	Database pulumi.StringPtrInput
   161  	// Brief explanation of the query. Maximum length of 1024.
   162  	Description pulumi.StringPtrInput
   163  	// Plain language name for the query. Maximum length of 128.
   164  	Name pulumi.StringPtrInput
   165  	// Text of the query itself. In other words, all query statements. Maximum length of 262144.
   166  	Query pulumi.StringPtrInput
   167  	// Workgroup to which the query belongs. Defaults to `primary`
   168  	Workgroup pulumi.StringPtrInput
   169  }
   170  
   171  func (NamedQueryState) ElementType() reflect.Type {
   172  	return reflect.TypeOf((*namedQueryState)(nil)).Elem()
   173  }
   174  
   175  type namedQueryArgs struct {
   176  	// Database to which the query belongs.
   177  	Database string `pulumi:"database"`
   178  	// Brief explanation of the query. Maximum length of 1024.
   179  	Description *string `pulumi:"description"`
   180  	// Plain language name for the query. Maximum length of 128.
   181  	Name *string `pulumi:"name"`
   182  	// Text of the query itself. In other words, all query statements. Maximum length of 262144.
   183  	Query string `pulumi:"query"`
   184  	// Workgroup to which the query belongs. Defaults to `primary`
   185  	Workgroup *string `pulumi:"workgroup"`
   186  }
   187  
   188  // The set of arguments for constructing a NamedQuery resource.
   189  type NamedQueryArgs struct {
   190  	// Database to which the query belongs.
   191  	Database pulumi.StringInput
   192  	// Brief explanation of the query. Maximum length of 1024.
   193  	Description pulumi.StringPtrInput
   194  	// Plain language name for the query. Maximum length of 128.
   195  	Name pulumi.StringPtrInput
   196  	// Text of the query itself. In other words, all query statements. Maximum length of 262144.
   197  	Query pulumi.StringInput
   198  	// Workgroup to which the query belongs. Defaults to `primary`
   199  	Workgroup pulumi.StringPtrInput
   200  }
   201  
   202  func (NamedQueryArgs) ElementType() reflect.Type {
   203  	return reflect.TypeOf((*namedQueryArgs)(nil)).Elem()
   204  }
   205  
   206  type NamedQueryInput interface {
   207  	pulumi.Input
   208  
   209  	ToNamedQueryOutput() NamedQueryOutput
   210  	ToNamedQueryOutputWithContext(ctx context.Context) NamedQueryOutput
   211  }
   212  
   213  func (*NamedQuery) ElementType() reflect.Type {
   214  	return reflect.TypeOf((**NamedQuery)(nil)).Elem()
   215  }
   216  
   217  func (i *NamedQuery) ToNamedQueryOutput() NamedQueryOutput {
   218  	return i.ToNamedQueryOutputWithContext(context.Background())
   219  }
   220  
   221  func (i *NamedQuery) ToNamedQueryOutputWithContext(ctx context.Context) NamedQueryOutput {
   222  	return pulumi.ToOutputWithContext(ctx, i).(NamedQueryOutput)
   223  }
   224  
   225  // NamedQueryArrayInput is an input type that accepts NamedQueryArray and NamedQueryArrayOutput values.
   226  // You can construct a concrete instance of `NamedQueryArrayInput` via:
   227  //
   228  //	NamedQueryArray{ NamedQueryArgs{...} }
   229  type NamedQueryArrayInput interface {
   230  	pulumi.Input
   231  
   232  	ToNamedQueryArrayOutput() NamedQueryArrayOutput
   233  	ToNamedQueryArrayOutputWithContext(context.Context) NamedQueryArrayOutput
   234  }
   235  
   236  type NamedQueryArray []NamedQueryInput
   237  
   238  func (NamedQueryArray) ElementType() reflect.Type {
   239  	return reflect.TypeOf((*[]*NamedQuery)(nil)).Elem()
   240  }
   241  
   242  func (i NamedQueryArray) ToNamedQueryArrayOutput() NamedQueryArrayOutput {
   243  	return i.ToNamedQueryArrayOutputWithContext(context.Background())
   244  }
   245  
   246  func (i NamedQueryArray) ToNamedQueryArrayOutputWithContext(ctx context.Context) NamedQueryArrayOutput {
   247  	return pulumi.ToOutputWithContext(ctx, i).(NamedQueryArrayOutput)
   248  }
   249  
   250  // NamedQueryMapInput is an input type that accepts NamedQueryMap and NamedQueryMapOutput values.
   251  // You can construct a concrete instance of `NamedQueryMapInput` via:
   252  //
   253  //	NamedQueryMap{ "key": NamedQueryArgs{...} }
   254  type NamedQueryMapInput interface {
   255  	pulumi.Input
   256  
   257  	ToNamedQueryMapOutput() NamedQueryMapOutput
   258  	ToNamedQueryMapOutputWithContext(context.Context) NamedQueryMapOutput
   259  }
   260  
   261  type NamedQueryMap map[string]NamedQueryInput
   262  
   263  func (NamedQueryMap) ElementType() reflect.Type {
   264  	return reflect.TypeOf((*map[string]*NamedQuery)(nil)).Elem()
   265  }
   266  
   267  func (i NamedQueryMap) ToNamedQueryMapOutput() NamedQueryMapOutput {
   268  	return i.ToNamedQueryMapOutputWithContext(context.Background())
   269  }
   270  
   271  func (i NamedQueryMap) ToNamedQueryMapOutputWithContext(ctx context.Context) NamedQueryMapOutput {
   272  	return pulumi.ToOutputWithContext(ctx, i).(NamedQueryMapOutput)
   273  }
   274  
   275  type NamedQueryOutput struct{ *pulumi.OutputState }
   276  
   277  func (NamedQueryOutput) ElementType() reflect.Type {
   278  	return reflect.TypeOf((**NamedQuery)(nil)).Elem()
   279  }
   280  
   281  func (o NamedQueryOutput) ToNamedQueryOutput() NamedQueryOutput {
   282  	return o
   283  }
   284  
   285  func (o NamedQueryOutput) ToNamedQueryOutputWithContext(ctx context.Context) NamedQueryOutput {
   286  	return o
   287  }
   288  
   289  // Database to which the query belongs.
   290  func (o NamedQueryOutput) Database() pulumi.StringOutput {
   291  	return o.ApplyT(func(v *NamedQuery) pulumi.StringOutput { return v.Database }).(pulumi.StringOutput)
   292  }
   293  
   294  // Brief explanation of the query. Maximum length of 1024.
   295  func (o NamedQueryOutput) Description() pulumi.StringPtrOutput {
   296  	return o.ApplyT(func(v *NamedQuery) pulumi.StringPtrOutput { return v.Description }).(pulumi.StringPtrOutput)
   297  }
   298  
   299  // Plain language name for the query. Maximum length of 128.
   300  func (o NamedQueryOutput) Name() pulumi.StringOutput {
   301  	return o.ApplyT(func(v *NamedQuery) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
   302  }
   303  
   304  // Text of the query itself. In other words, all query statements. Maximum length of 262144.
   305  func (o NamedQueryOutput) Query() pulumi.StringOutput {
   306  	return o.ApplyT(func(v *NamedQuery) pulumi.StringOutput { return v.Query }).(pulumi.StringOutput)
   307  }
   308  
   309  // Workgroup to which the query belongs. Defaults to `primary`
   310  func (o NamedQueryOutput) Workgroup() pulumi.StringPtrOutput {
   311  	return o.ApplyT(func(v *NamedQuery) pulumi.StringPtrOutput { return v.Workgroup }).(pulumi.StringPtrOutput)
   312  }
   313  
   314  type NamedQueryArrayOutput struct{ *pulumi.OutputState }
   315  
   316  func (NamedQueryArrayOutput) ElementType() reflect.Type {
   317  	return reflect.TypeOf((*[]*NamedQuery)(nil)).Elem()
   318  }
   319  
   320  func (o NamedQueryArrayOutput) ToNamedQueryArrayOutput() NamedQueryArrayOutput {
   321  	return o
   322  }
   323  
   324  func (o NamedQueryArrayOutput) ToNamedQueryArrayOutputWithContext(ctx context.Context) NamedQueryArrayOutput {
   325  	return o
   326  }
   327  
   328  func (o NamedQueryArrayOutput) Index(i pulumi.IntInput) NamedQueryOutput {
   329  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *NamedQuery {
   330  		return vs[0].([]*NamedQuery)[vs[1].(int)]
   331  	}).(NamedQueryOutput)
   332  }
   333  
   334  type NamedQueryMapOutput struct{ *pulumi.OutputState }
   335  
   336  func (NamedQueryMapOutput) ElementType() reflect.Type {
   337  	return reflect.TypeOf((*map[string]*NamedQuery)(nil)).Elem()
   338  }
   339  
   340  func (o NamedQueryMapOutput) ToNamedQueryMapOutput() NamedQueryMapOutput {
   341  	return o
   342  }
   343  
   344  func (o NamedQueryMapOutput) ToNamedQueryMapOutputWithContext(ctx context.Context) NamedQueryMapOutput {
   345  	return o
   346  }
   347  
   348  func (o NamedQueryMapOutput) MapIndex(k pulumi.StringInput) NamedQueryOutput {
   349  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *NamedQuery {
   350  		return vs[0].(map[string]*NamedQuery)[vs[1].(string)]
   351  	}).(NamedQueryOutput)
   352  }
   353  
   354  func init() {
   355  	pulumi.RegisterInputType(reflect.TypeOf((*NamedQueryInput)(nil)).Elem(), &NamedQuery{})
   356  	pulumi.RegisterInputType(reflect.TypeOf((*NamedQueryArrayInput)(nil)).Elem(), NamedQueryArray{})
   357  	pulumi.RegisterInputType(reflect.TypeOf((*NamedQueryMapInput)(nil)).Elem(), NamedQueryMap{})
   358  	pulumi.RegisterOutputType(NamedQueryOutput{})
   359  	pulumi.RegisterOutputType(NamedQueryArrayOutput{})
   360  	pulumi.RegisterOutputType(NamedQueryMapOutput{})
   361  }