Namespace Pulumi.Aws.AppSync
Classes
ApiKey
Provides an AppSync API Key.
Example Usage
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var exampleGraphQLApi = new Aws.AppSync.GraphQLApi("exampleGraphQLApi", new Aws.AppSync.GraphQLApiArgs
{
AuthenticationType = "API_KEY",
});
var exampleApiKey = new Aws.AppSync.ApiKey("exampleApiKey", new Aws.AppSync.ApiKeyArgs
{
ApiId = exampleGraphQLApi.Id,
Expires = "2018-05-03T04:00:00Z",
});
}
}
ApiKeyArgs
ApiKeyState
DataSource
Provides an AppSync DataSource.
Example Usage
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var exampleTable = new Aws.DynamoDB.Table("exampleTable", new Aws.DynamoDB.TableArgs
{
Attributes =
{
new Aws.DynamoDB.Inputs.TableAttributeArgs
{
Name = "UserId",
Type = "S",
},
},
HashKey = "UserId",
ReadCapacity = 1,
WriteCapacity = 1,
});
var exampleRole = new Aws.Iam.Role("exampleRole", new Aws.Iam.RoleArgs
{
AssumeRolePolicy = @"{
""Version"": ""2012-10-17"",
""Statement"": [
{
""Action"": ""sts:AssumeRole"",
""Principal"": {
""Service"": ""appsync.amazonaws.com""
},
""Effect"": ""Allow""
}
]
}
",
});
var exampleRolePolicy = new Aws.Iam.RolePolicy("exampleRolePolicy", new Aws.Iam.RolePolicyArgs
{
Policy = exampleTable.Arn.Apply(arn => @$"{{
""Version"": ""2012-10-17"",
""Statement"": [
{{
""Action"": [
""dynamodb:*""
],
""Effect"": ""Allow"",
""Resource"": [
""{arn}""
]
}}
]
}}
"),
Role = exampleRole.Id,
});
var exampleGraphQLApi = new Aws.AppSync.GraphQLApi("exampleGraphQLApi", new Aws.AppSync.GraphQLApiArgs
{
AuthenticationType = "API_KEY",
});
var exampleDataSource = new Aws.AppSync.DataSource("exampleDataSource", new Aws.AppSync.DataSourceArgs
{
ApiId = exampleGraphQLApi.Id,
DynamodbConfig = new Aws.AppSync.Inputs.DataSourceDynamodbConfigArgs
{
TableName = exampleTable.Name,
},
ServiceRoleArn = exampleRole.Arn,
Type = "AMAZON_DYNAMODB",
});
}
}
DataSourceArgs
DataSourceState
Function
Provides an AppSync Function.
Example Usage
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var testGraphQLApi = new Aws.AppSync.GraphQLApi("testGraphQLApi", new Aws.AppSync.GraphQLApiArgs
{
AuthenticationType = "API_KEY",
Schema = @"type Mutation {
putPost(id: ID!, title: String!): Post
}
type Post {
id: ID!
title: String!
}
type Query {
singlePost(id: ID!): Post
}
schema {
query: Query
mutation: Mutation
}
",
});
var testDataSource = new Aws.AppSync.DataSource("testDataSource", new Aws.AppSync.DataSourceArgs
{
ApiId = testGraphQLApi.Id,
HttpConfig = new Aws.AppSync.Inputs.DataSourceHttpConfigArgs
{
Endpoint = "http://example.com",
},
Type = "HTTP",
});
var testFunction = new Aws.AppSync.Function("testFunction", new Aws.AppSync.FunctionArgs
{
ApiId = testGraphQLApi.Id,
DataSource = testDataSource.Name,
Name = "tf_example",
RequestMappingTemplate = @"{
""version"": ""2018-05-29"",
""method"": ""GET"",
""resourcePath"": ""/"",
""params"":{
""headers"": $$utils.http.copyheaders($$ctx.request.headers)
}
}
",
ResponseMappingTemplate = @"#if($$ctx.result.statusCode == 200)
$$ctx.result.body
#else
$$utils.appendError($$ctx.result.body, $$ctx.result.statusCode)
#end
",
});
}
}
FunctionArgs
FunctionState
GraphQLApi
Provides an AppSync GraphQL API.
Example Usage
API Key Authentication
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var example = new Aws.AppSync.GraphQLApi("example", new Aws.AppSync.GraphQLApiArgs
{
AuthenticationType = "API_KEY",
});
}
}
AWS Cognito User Pool Authentication
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var example = new Aws.AppSync.GraphQLApi("example", new Aws.AppSync.GraphQLApiArgs
{
AuthenticationType = "AMAZON_COGNITO_USER_POOLS",
UserPoolConfig = new Aws.AppSync.Inputs.GraphQLApiUserPoolConfigArgs
{
AwsRegion = data.Aws_region.Current.Name,
DefaultAction = "DENY",
UserPoolId = aws_cognito_user_pool.Example.Id,
},
});
}
}
AWS IAM Authentication
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var example = new Aws.AppSync.GraphQLApi("example", new Aws.AppSync.GraphQLApiArgs
{
AuthenticationType = "AWS_IAM",
});
}
}
With Schema
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var example = new Aws.AppSync.GraphQLApi("example", new Aws.AppSync.GraphQLApiArgs
{
AuthenticationType = "AWS_IAM",
Schema = @"schema {
query: Query
}
type Query {
test: Int
}
",
});
}
}
OpenID Connect Authentication
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var example = new Aws.AppSync.GraphQLApi("example", new Aws.AppSync.GraphQLApiArgs
{
AuthenticationType = "OPENID_CONNECT",
OpenidConnectConfig = new Aws.AppSync.Inputs.GraphQLApiOpenidConnectConfigArgs
{
Issuer = "https://example.com",
},
});
}
}
With Multiple Authentication Providers
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var example = new Aws.AppSync.GraphQLApi("example", new Aws.AppSync.GraphQLApiArgs
{
AdditionalAuthenticationProviders =
{
new Aws.AppSync.Inputs.GraphQLApiAdditionalAuthenticationProviderArgs
{
AuthenticationType = "AWS_IAM",
},
},
AuthenticationType = "API_KEY",
});
}
}
Enabling Logging
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var exampleRole = new Aws.Iam.Role("exampleRole", new Aws.Iam.RoleArgs
{
AssumeRolePolicy = @"{
""Version"": ""2012-10-17"",
""Statement"": [
{
""Effect"": ""Allow"",
""Principal"": {
""Service"": ""appsync.amazonaws.com""
},
""Action"": ""sts:AssumeRole""
}
]
}
",
});
var exampleRolePolicyAttachment = new Aws.Iam.RolePolicyAttachment("exampleRolePolicyAttachment", new Aws.Iam.RolePolicyAttachmentArgs
{
PolicyArn = "arn:aws:iam::aws:policy/service-role/AWSAppSyncPushToCloudWatchLogs",
Role = exampleRole.Name,
});
var exampleGraphQLApi = new Aws.AppSync.GraphQLApi("exampleGraphQLApi", new Aws.AppSync.GraphQLApiArgs
{
LogConfig = new Aws.AppSync.Inputs.GraphQLApiLogConfigArgs
{
CloudwatchLogsRoleArn = exampleRole.Arn,
FieldLogLevel = "ERROR",
},
});
}
}
GraphQLApiArgs
GraphQLApiState
Resolver
Provides an AppSync Resolver.
Example Usage
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var testGraphQLApi = new Aws.AppSync.GraphQLApi("testGraphQLApi", new Aws.AppSync.GraphQLApiArgs
{
AuthenticationType = "API_KEY",
Schema = @"type Mutation {
putPost(id: ID!, title: String!): Post
}
type Post {
id: ID!
title: String!
}
type Query {
singlePost(id: ID!): Post
}
schema {
query: Query
mutation: Mutation
}
",
});
var testDataSource = new Aws.AppSync.DataSource("testDataSource", new Aws.AppSync.DataSourceArgs
{
ApiId = testGraphQLApi.Id,
HttpConfig = new Aws.AppSync.Inputs.DataSourceHttpConfigArgs
{
Endpoint = "http://example.com",
},
Type = "HTTP",
});
// UNIT type resolver (default)
var testResolver = new Aws.AppSync.Resolver("testResolver", new Aws.AppSync.ResolverArgs
{
ApiId = testGraphQLApi.Id,
CachingConfig = new Aws.AppSync.Inputs.ResolverCachingConfigArgs
{
CachingKeys =
{
"$$context.identity.sub",
"$$context.arguments.id",
},
Ttl = 60,
},
DataSource = testDataSource.Name,
Field = "singlePost",
RequestTemplate = @"{
""version"": ""2018-05-29"",
""method"": ""GET"",
""resourcePath"": ""/"",
""params"":{
""headers"": $$utils.http.copyheaders($$ctx.request.headers)
}
}
",
ResponseTemplate = @"#if($$ctx.result.statusCode == 200)
$$ctx.result.body
#else
$$utils.appendError($$ctx.result.body, $$ctx.result.statusCode)
#end
",
Type = "Query",
});
// PIPELINE type resolver
var mutationPipelineTest = new Aws.AppSync.Resolver("mutationPipelineTest", new Aws.AppSync.ResolverArgs
{
ApiId = testGraphQLApi.Id,
Field = "pipelineTest",
Kind = "PIPELINE",
PipelineConfig = new Aws.AppSync.Inputs.ResolverPipelineConfigArgs
{
Functions =
{
aws_appsync_function.Test1.Function_id,
aws_appsync_function.Test2.Function_id,
aws_appsync_function.Test3.Function_id,
},
},
RequestTemplate = "{}",
ResponseTemplate = "$$util.toJson($$ctx.result)",
Type = "Mutation",
});
}
}