aws.athena.NamedQuery
Explore with Pulumi AI
Provides an Athena Named Query resource.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const hoge = new aws.s3.BucketV2("hoge", {bucket: "tf-test"});
const test = new aws.kms.Key("test", {
deletionWindowInDays: 7,
description: "Athena KMS Key",
});
const testWorkgroup = new aws.athena.Workgroup("test", {
name: "example",
configuration: {
resultConfiguration: {
encryptionConfiguration: {
encryptionOption: "SSE_KMS",
kmsKeyArn: test.arn,
},
},
},
});
const hogeDatabase = new aws.athena.Database("hoge", {
name: "users",
bucket: hoge.id,
});
const foo = new aws.athena.NamedQuery("foo", {
name: "bar",
workgroup: testWorkgroup.id,
database: hogeDatabase.name,
query: pulumi.interpolate`SELECT * FROM ${hogeDatabase.name} limit 10;`,
});
import pulumi
import pulumi_aws as aws
hoge = aws.s3.BucketV2("hoge", bucket="tf-test")
test = aws.kms.Key("test",
deletion_window_in_days=7,
description="Athena KMS Key")
test_workgroup = aws.athena.Workgroup("test",
name="example",
configuration={
"result_configuration": {
"encryption_configuration": {
"encryption_option": "SSE_KMS",
"kms_key_arn": test.arn,
},
},
})
hoge_database = aws.athena.Database("hoge",
name="users",
bucket=hoge.id)
foo = aws.athena.NamedQuery("foo",
name="bar",
workgroup=test_workgroup.id,
database=hoge_database.name,
query=hoge_database.name.apply(lambda name: f"SELECT * FROM {name} limit 10;"))
package main
import (
"fmt"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/athena"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/kms"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
hoge, err := s3.NewBucketV2(ctx, "hoge", &s3.BucketV2Args{
Bucket: pulumi.String("tf-test"),
})
if err != nil {
return err
}
test, err := kms.NewKey(ctx, "test", &kms.KeyArgs{
DeletionWindowInDays: pulumi.Int(7),
Description: pulumi.String("Athena KMS Key"),
})
if err != nil {
return err
}
testWorkgroup, err := athena.NewWorkgroup(ctx, "test", &athena.WorkgroupArgs{
Name: pulumi.String("example"),
Configuration: &athena.WorkgroupConfigurationArgs{
ResultConfiguration: &athena.WorkgroupConfigurationResultConfigurationArgs{
EncryptionConfiguration: &athena.WorkgroupConfigurationResultConfigurationEncryptionConfigurationArgs{
EncryptionOption: pulumi.String("SSE_KMS"),
KmsKeyArn: test.Arn,
},
},
},
})
if err != nil {
return err
}
hogeDatabase, err := athena.NewDatabase(ctx, "hoge", &athena.DatabaseArgs{
Name: pulumi.String("users"),
Bucket: hoge.ID(),
})
if err != nil {
return err
}
_, err = athena.NewNamedQuery(ctx, "foo", &athena.NamedQueryArgs{
Name: pulumi.String("bar"),
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
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var hoge = new Aws.S3.BucketV2("hoge", new()
{
Bucket = "tf-test",
});
var test = new Aws.Kms.Key("test", new()
{
DeletionWindowInDays = 7,
Description = "Athena KMS Key",
});
var testWorkgroup = new Aws.Athena.Workgroup("test", new()
{
Name = "example",
Configuration = new Aws.Athena.Inputs.WorkgroupConfigurationArgs
{
ResultConfiguration = new Aws.Athena.Inputs.WorkgroupConfigurationResultConfigurationArgs
{
EncryptionConfiguration = new Aws.Athena.Inputs.WorkgroupConfigurationResultConfigurationEncryptionConfigurationArgs
{
EncryptionOption = "SSE_KMS",
KmsKeyArn = test.Arn,
},
},
},
});
var hogeDatabase = new Aws.Athena.Database("hoge", new()
{
Name = "users",
Bucket = hoge.Id,
});
var foo = new Aws.Athena.NamedQuery("foo", new()
{
Name = "bar",
Workgroup = testWorkgroup.Id,
Database = hogeDatabase.Name,
Query = hogeDatabase.Name.Apply(name => $"SELECT * FROM {name} limit 10;"),
});
});
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.s3.BucketV2Args;
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 hoge = new BucketV2("hoge", BucketV2Args.builder()
.bucket("tf-test")
.build());
var test = new Key("test", KeyArgs.builder()
.deletionWindowInDays(7)
.description("Athena KMS Key")
.build());
var testWorkgroup = new Workgroup("testWorkgroup", WorkgroupArgs.builder()
.name("example")
.configuration(WorkgroupConfigurationArgs.builder()
.resultConfiguration(WorkgroupConfigurationResultConfigurationArgs.builder()
.encryptionConfiguration(WorkgroupConfigurationResultConfigurationEncryptionConfigurationArgs.builder()
.encryptionOption("SSE_KMS")
.kmsKeyArn(test.arn())
.build())
.build())
.build())
.build());
var hogeDatabase = new Database("hogeDatabase", DatabaseArgs.builder()
.name("users")
.bucket(hoge.id())
.build());
var foo = new NamedQuery("foo", NamedQueryArgs.builder()
.name("bar")
.workgroup(testWorkgroup.id())
.database(hogeDatabase.name())
.query(hogeDatabase.name().applyValue(name -> String.format("SELECT * FROM %s limit 10;", name)))
.build());
}
}
resources:
hoge:
type: aws:s3:BucketV2
properties:
bucket: tf-test
test:
type: aws:kms:Key
properties:
deletionWindowInDays: 7
description: Athena KMS Key
testWorkgroup:
type: aws:athena:Workgroup
name: test
properties:
name: example
configuration:
resultConfiguration:
encryptionConfiguration:
encryptionOption: SSE_KMS
kmsKeyArn: ${test.arn}
hogeDatabase:
type: aws:athena:Database
name: hoge
properties:
name: users
bucket: ${hoge.id}
foo:
type: aws:athena:NamedQuery
properties:
name: bar
workgroup: ${testWorkgroup.id}
database: ${hogeDatabase.name}
query: SELECT * FROM ${hogeDatabase.name} limit 10;
Create NamedQuery Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new NamedQuery(name: string, args: NamedQueryArgs, opts?: CustomResourceOptions);
@overload
def NamedQuery(resource_name: str,
args: NamedQueryArgs,
opts: Optional[ResourceOptions] = None)
@overload
def NamedQuery(resource_name: str,
opts: Optional[ResourceOptions] = None,
database: Optional[str] = None,
query: Optional[str] = None,
description: Optional[str] = None,
name: Optional[str] = None,
workgroup: Optional[str] = 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.
Parameters
- 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.
Constructor example
The following reference example uses placeholder values for all input properties.
var namedQueryResource = new Aws.Athena.NamedQuery("namedQueryResource", new()
{
Database = "string",
Query = "string",
Description = "string",
Name = "string",
Workgroup = "string",
});
example, err := athena.NewNamedQuery(ctx, "namedQueryResource", &athena.NamedQueryArgs{
Database: pulumi.String("string"),
Query: pulumi.String("string"),
Description: pulumi.String("string"),
Name: pulumi.String("string"),
Workgroup: pulumi.String("string"),
})
var namedQueryResource = new NamedQuery("namedQueryResource", NamedQueryArgs.builder()
.database("string")
.query("string")
.description("string")
.name("string")
.workgroup("string")
.build());
named_query_resource = aws.athena.NamedQuery("namedQueryResource",
database="string",
query="string",
description="string",
name="string",
workgroup="string")
const namedQueryResource = new aws.athena.NamedQuery("namedQueryResource", {
database: "string",
query: "string",
description: "string",
name: "string",
workgroup: "string",
});
type: aws:athena:NamedQuery
properties:
database: string
description: string
name: string
query: string
workgroup: string
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
Using pulumi import
, import Athena Named Query using the query ID. For example:
$ pulumi import aws:athena/namedQuery:NamedQuery example 0123456789
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- AWS Classic pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
aws
Terraform Provider.