aws.athena.NamedQuery
Explore with Pulumi AI
Provides an Athena Named Query resource.
Example Usage
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var hogeBucketV2 = new Aws.S3.BucketV2("hogeBucketV2");
var testKey = new Aws.Kms.Key("testKey", new()
{
DeletionWindowInDays = 7,
Description = "Athena KMS Key",
});
var testWorkgroup = new Aws.Athena.Workgroup("testWorkgroup", new()
{
Configuration = new Aws.Athena.Inputs.WorkgroupConfigurationArgs
{
ResultConfiguration = new Aws.Athena.Inputs.WorkgroupConfigurationResultConfigurationArgs
{
EncryptionConfiguration = new Aws.Athena.Inputs.WorkgroupConfigurationResultConfigurationEncryptionConfigurationArgs
{
EncryptionOption = "SSE_KMS",
KmsKeyArn = testKey.Arn,
},
},
},
});
var hogeDatabase = new Aws.Athena.Database("hogeDatabase", new()
{
Name = "users",
Bucket = hogeBucketV2.Id,
});
var foo = new Aws.Athena.NamedQuery("foo", new()
{
Workgroup = testWorkgroup.Id,
Database = hogeDatabase.Name,
Query = hogeDatabase.Name.Apply(name => $"SELECT * FROM {name} limit 10;"),
});
});
package main
import (
"fmt"
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/athena"
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/kms"
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/s3"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
hogeBucketV2, err := s3.NewBucketV2(ctx, "hogeBucketV2", nil)
if err != nil {
return err
}
testKey, err := kms.NewKey(ctx, "testKey", &kms.KeyArgs{
DeletionWindowInDays: pulumi.Int(7),
Description: pulumi.String("Athena KMS Key"),
})
if err != nil {
return err
}
testWorkgroup, err := athena.NewWorkgroup(ctx, "testWorkgroup", &athena.WorkgroupArgs{
Configuration: &athena.WorkgroupConfigurationArgs{
ResultConfiguration: &athena.WorkgroupConfigurationResultConfigurationArgs{
EncryptionConfiguration: &athena.WorkgroupConfigurationResultConfigurationEncryptionConfigurationArgs{
EncryptionOption: pulumi.String("SSE_KMS"),
KmsKeyArn: testKey.Arn,
},
},
},
})
if err != nil {
return err
}
hogeDatabase, err := athena.NewDatabase(ctx, "hogeDatabase", &athena.DatabaseArgs{
Name: pulumi.String("users"),
Bucket: hogeBucketV2.ID(),
})
if err != nil {
return err
}
_, err = athena.NewNamedQuery(ctx, "foo", &athena.NamedQueryArgs{
Workgroup: testWorkgroup.ID(),
Database: hogeDatabase.Name,
Query: hogeDatabase.Name.ApplyT(func(name string) (string, error) {
return fmt.Sprintf("SELECT * FROM %v limit 10;", name), nil
}).(pulumi.StringOutput),
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.s3.BucketV2;
import com.pulumi.aws.kms.Key;
import com.pulumi.aws.kms.KeyArgs;
import com.pulumi.aws.athena.Workgroup;
import com.pulumi.aws.athena.WorkgroupArgs;
import com.pulumi.aws.athena.inputs.WorkgroupConfigurationArgs;
import com.pulumi.aws.athena.inputs.WorkgroupConfigurationResultConfigurationArgs;
import com.pulumi.aws.athena.inputs.WorkgroupConfigurationResultConfigurationEncryptionConfigurationArgs;
import com.pulumi.aws.athena.Database;
import com.pulumi.aws.athena.DatabaseArgs;
import com.pulumi.aws.athena.NamedQuery;
import com.pulumi.aws.athena.NamedQueryArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var hogeBucketV2 = new BucketV2("hogeBucketV2");
var testKey = new Key("testKey", KeyArgs.builder()
.deletionWindowInDays(7)
.description("Athena KMS Key")
.build());
var testWorkgroup = new Workgroup("testWorkgroup", WorkgroupArgs.builder()
.configuration(WorkgroupConfigurationArgs.builder()
.resultConfiguration(WorkgroupConfigurationResultConfigurationArgs.builder()
.encryptionConfiguration(WorkgroupConfigurationResultConfigurationEncryptionConfigurationArgs.builder()
.encryptionOption("SSE_KMS")
.kmsKeyArn(testKey.arn())
.build())
.build())
.build())
.build());
var hogeDatabase = new Database("hogeDatabase", DatabaseArgs.builder()
.name("users")
.bucket(hogeBucketV2.id())
.build());
var foo = new NamedQuery("foo", NamedQueryArgs.builder()
.workgroup(testWorkgroup.id())
.database(hogeDatabase.name())
.query(hogeDatabase.name().applyValue(name -> String.format("SELECT * FROM %s limit 10;", name)))
.build());
}
}
import pulumi
import pulumi_aws as aws
hoge_bucket_v2 = aws.s3.BucketV2("hogeBucketV2")
test_key = aws.kms.Key("testKey",
deletion_window_in_days=7,
description="Athena KMS Key")
test_workgroup = aws.athena.Workgroup("testWorkgroup", configuration=aws.athena.WorkgroupConfigurationArgs(
result_configuration=aws.athena.WorkgroupConfigurationResultConfigurationArgs(
encryption_configuration=aws.athena.WorkgroupConfigurationResultConfigurationEncryptionConfigurationArgs(
encryption_option="SSE_KMS",
kms_key_arn=test_key.arn,
),
),
))
hoge_database = aws.athena.Database("hogeDatabase",
name="users",
bucket=hoge_bucket_v2.id)
foo = aws.athena.NamedQuery("foo",
workgroup=test_workgroup.id,
database=hoge_database.name,
query=hoge_database.name.apply(lambda name: f"SELECT * FROM {name} limit 10;"))
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const hogeBucketV2 = new aws.s3.BucketV2("hogeBucketV2", {});
const testKey = new aws.kms.Key("testKey", {
deletionWindowInDays: 7,
description: "Athena KMS Key",
});
const testWorkgroup = new aws.athena.Workgroup("testWorkgroup", {configuration: {
resultConfiguration: {
encryptionConfiguration: {
encryptionOption: "SSE_KMS",
kmsKeyArn: testKey.arn,
},
},
}});
const hogeDatabase = new aws.athena.Database("hogeDatabase", {
name: "users",
bucket: hogeBucketV2.id,
});
const foo = new aws.athena.NamedQuery("foo", {
workgroup: testWorkgroup.id,
database: hogeDatabase.name,
query: pulumi.interpolate`SELECT * FROM ${hogeDatabase.name} limit 10;`,
});
resources:
hogeBucketV2:
type: aws:s3:BucketV2
testKey:
type: aws:kms:Key
properties:
deletionWindowInDays: 7
description: Athena KMS Key
testWorkgroup:
type: aws:athena:Workgroup
properties:
configuration:
resultConfiguration:
encryptionConfiguration:
encryptionOption: SSE_KMS
kmsKeyArn: ${testKey.arn}
hogeDatabase:
type: aws:athena:Database
properties:
name: users
bucket: ${hogeBucketV2.id}
foo:
type: aws:athena:NamedQuery
properties:
workgroup: ${testWorkgroup.id}
database: ${hogeDatabase.name}
query: SELECT * FROM ${hogeDatabase.name} limit 10;
Create NamedQuery Resource
new NamedQuery(name: string, args: NamedQueryArgs, opts?: CustomResourceOptions);
@overload
def NamedQuery(resource_name: str,
opts: Optional[ResourceOptions] = None,
database: Optional[str] = None,
description: Optional[str] = None,
name: Optional[str] = None,
query: Optional[str] = None,
workgroup: Optional[str] = None)
@overload
def NamedQuery(resource_name: str,
args: NamedQueryArgs,
opts: Optional[ResourceOptions] = None)
func NewNamedQuery(ctx *Context, name string, args NamedQueryArgs, opts ...ResourceOption) (*NamedQuery, error)
public NamedQuery(string name, NamedQueryArgs args, CustomResourceOptions? opts = null)
public NamedQuery(String name, NamedQueryArgs args)
public NamedQuery(String name, NamedQueryArgs args, CustomResourceOptions options)
type: aws:athena:NamedQuery
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args NamedQueryArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args NamedQueryArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args NamedQueryArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args NamedQueryArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args NamedQueryArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
NamedQuery Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
The NamedQuery resource accepts the following input properties:
- Database string
Database to which the query belongs.
- Query string
Text of the query itself. In other words, all query statements. Maximum length of 262144.
- Description string
Brief explanation of the query. Maximum length of 1024.
- Name string
Plain language name for the query. Maximum length of 128.
- Workgroup string
Workgroup to which the query belongs. Defaults to
primary
- Database string
Database to which the query belongs.
- Query string
Text of the query itself. In other words, all query statements. Maximum length of 262144.
- Description string
Brief explanation of the query. Maximum length of 1024.
- Name string
Plain language name for the query. Maximum length of 128.
- Workgroup string
Workgroup to which the query belongs. Defaults to
primary
- database String
Database to which the query belongs.
- query String
Text of the query itself. In other words, all query statements. Maximum length of 262144.
- description String
Brief explanation of the query. Maximum length of 1024.
- name String
Plain language name for the query. Maximum length of 128.
- workgroup String
Workgroup to which the query belongs. Defaults to
primary
- database string
Database to which the query belongs.
- query string
Text of the query itself. In other words, all query statements. Maximum length of 262144.
- description string
Brief explanation of the query. Maximum length of 1024.
- name string
Plain language name for the query. Maximum length of 128.
- workgroup string
Workgroup to which the query belongs. Defaults to
primary
- database str
Database to which the query belongs.
- query str
Text of the query itself. In other words, all query statements. Maximum length of 262144.
- description str
Brief explanation of the query. Maximum length of 1024.
- name str
Plain language name for the query. Maximum length of 128.
- workgroup str
Workgroup to which the query belongs. Defaults to
primary
- database String
Database to which the query belongs.
- query String
Text of the query itself. In other words, all query statements. Maximum length of 262144.
- description String
Brief explanation of the query. Maximum length of 1024.
- name String
Plain language name for the query. Maximum length of 128.
- workgroup String
Workgroup to which the query belongs. Defaults to
primary
Outputs
All input properties are implicitly available as output properties. Additionally, the NamedQuery resource produces the following output properties:
- Id string
The provider-assigned unique ID for this managed resource.
- Id string
The provider-assigned unique ID for this managed resource.
- id String
The provider-assigned unique ID for this managed resource.
- id string
The provider-assigned unique ID for this managed resource.
- id str
The provider-assigned unique ID for this managed resource.
- id String
The provider-assigned unique ID for this managed resource.
Look up Existing NamedQuery Resource
Get an existing NamedQuery resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: NamedQueryState, opts?: CustomResourceOptions): NamedQuery
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
database: Optional[str] = None,
description: Optional[str] = None,
name: Optional[str] = None,
query: Optional[str] = None,
workgroup: Optional[str] = None) -> NamedQuery
func GetNamedQuery(ctx *Context, name string, id IDInput, state *NamedQueryState, opts ...ResourceOption) (*NamedQuery, error)
public static NamedQuery Get(string name, Input<string> id, NamedQueryState? state, CustomResourceOptions? opts = null)
public static NamedQuery get(String name, Output<String> id, NamedQueryState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Database string
Database to which the query belongs.
- Description string
Brief explanation of the query. Maximum length of 1024.
- Name string
Plain language name for the query. Maximum length of 128.
- Query string
Text of the query itself. In other words, all query statements. Maximum length of 262144.
- Workgroup string
Workgroup to which the query belongs. Defaults to
primary
- Database string
Database to which the query belongs.
- Description string
Brief explanation of the query. Maximum length of 1024.
- Name string
Plain language name for the query. Maximum length of 128.
- Query string
Text of the query itself. In other words, all query statements. Maximum length of 262144.
- Workgroup string
Workgroup to which the query belongs. Defaults to
primary
- database String
Database to which the query belongs.
- description String
Brief explanation of the query. Maximum length of 1024.
- name String
Plain language name for the query. Maximum length of 128.
- query String
Text of the query itself. In other words, all query statements. Maximum length of 262144.
- workgroup String
Workgroup to which the query belongs. Defaults to
primary
- database string
Database to which the query belongs.
- description string
Brief explanation of the query. Maximum length of 1024.
- name string
Plain language name for the query. Maximum length of 128.
- query string
Text of the query itself. In other words, all query statements. Maximum length of 262144.
- workgroup string
Workgroup to which the query belongs. Defaults to
primary
- database str
Database to which the query belongs.
- description str
Brief explanation of the query. Maximum length of 1024.
- name str
Plain language name for the query. Maximum length of 128.
- query str
Text of the query itself. In other words, all query statements. Maximum length of 262144.
- workgroup str
Workgroup to which the query belongs. Defaults to
primary
- database String
Database to which the query belongs.
- description String
Brief explanation of the query. Maximum length of 1024.
- name String
Plain language name for the query. Maximum length of 128.
- query String
Text of the query itself. In other words, all query statements. Maximum length of 262144.
- workgroup String
Workgroup to which the query belongs. Defaults to
primary
Import
Athena Named Query can be imported using the query ID, e.g.,
$ pulumi import aws:athena/namedQuery:NamedQuery example 0123456789
Package Details
- Repository
- AWS Classic pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
This Pulumi package is based on the
aws
Terraform Provider.