@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
309 lines • 10.8 kB
JavaScript
"use strict";
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.GraphQLApi = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Provides an AppSync GraphQL API.
*
* ## Example Usage
*
* ### API Key Authentication
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.appsync.GraphQLApi("example", {
* authenticationType: "API_KEY",
* name: "example",
* });
* ```
*
* ### AWS IAM Authentication
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.appsync.GraphQLApi("example", {
* authenticationType: "AWS_IAM",
* name: "example",
* });
* ```
*
* ### AWS Cognito User Pool Authentication
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.appsync.GraphQLApi("example", {
* authenticationType: "AMAZON_COGNITO_USER_POOLS",
* name: "example",
* userPoolConfig: {
* awsRegion: current.region,
* defaultAction: "DENY",
* userPoolId: exampleAwsCognitoUserPool.id,
* },
* });
* ```
*
* ### OpenID Connect Authentication
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.appsync.GraphQLApi("example", {
* authenticationType: "OPENID_CONNECT",
* name: "example",
* openidConnectConfig: {
* issuer: "https://example.com",
* },
* });
* ```
*
* ### AWS Lambda Authorizer Authentication
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.appsync.GraphQLApi("example", {
* authenticationType: "AWS_LAMBDA",
* name: "example",
* lambdaAuthorizerConfig: {
* authorizerUri: "arn:aws:lambda:us-east-1:123456789012:function:custom_lambda_authorizer",
* },
* });
* const appsyncLambdaAuthorizer = new aws.lambda.Permission("appsync_lambda_authorizer", {
* statementId: "appsync_lambda_authorizer",
* action: "lambda:InvokeFunction",
* "function": "custom_lambda_authorizer",
* principal: "appsync.amazonaws.com",
* sourceArn: example.arn,
* });
* ```
*
* ### With Multiple Authentication Providers
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.appsync.GraphQLApi("example", {
* authenticationType: "API_KEY",
* name: "example",
* additionalAuthenticationProviders: [{
* authenticationType: "AWS_IAM",
* }],
* });
* ```
*
* ### With Schema
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.appsync.GraphQLApi("example", {
* authenticationType: "AWS_IAM",
* name: "example",
* schema: `schema {
* \\tquery: Query
* }
* type Query {
* test: Int
* }
* `,
* });
* ```
*
* ### Enabling Logging
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const assumeRole = aws.iam.getPolicyDocument({
* statements: [{
* effect: "Allow",
* principals: [{
* type: "Service",
* identifiers: ["appsync.amazonaws.com"],
* }],
* actions: ["sts:AssumeRole"],
* }],
* });
* const example = new aws.iam.Role("example", {
* name: "example",
* assumeRolePolicy: assumeRole.then(assumeRole => assumeRole.json),
* });
* const exampleRolePolicyAttachment = new aws.iam.RolePolicyAttachment("example", {
* policyArn: "arn:aws:iam::aws:policy/service-role/AWSAppSyncPushToCloudWatchLogs",
* role: example.name,
* });
* const exampleGraphQLApi = new aws.appsync.GraphQLApi("example", {logConfig: {
* cloudwatchLogsRoleArn: example.arn,
* fieldLogLevel: "ERROR",
* }});
* ```
*
* ### Associate Web ACL (v2)
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.appsync.GraphQLApi("example", {
* authenticationType: "API_KEY",
* name: "example",
* });
* const exampleWebAcl = new aws.wafv2.WebAcl("example", {
* name: "managed-rule-example",
* description: "Example of a managed rule.",
* scope: "REGIONAL",
* defaultAction: {
* allow: {},
* },
* rules: [{
* name: "rule-1",
* priority: 1,
* overrideAction: {
* block: [{}],
* },
* statement: {
* managedRuleGroupStatement: {
* name: "AWSManagedRulesCommonRuleSet",
* vendorName: "AWS",
* },
* },
* visibilityConfig: {
* cloudwatchMetricsEnabled: false,
* metricName: "friendly-rule-metric-name",
* sampledRequestsEnabled: false,
* },
* }],
* visibilityConfig: {
* cloudwatchMetricsEnabled: false,
* metricName: "friendly-metric-name",
* sampledRequestsEnabled: false,
* },
* });
* const exampleWebAclAssociation = new aws.wafv2.WebAclAssociation("example", {
* resourceArn: example.arn,
* webAclArn: exampleWebAcl.arn,
* });
* ```
*
* ### GraphQL run complexity, query depth, and introspection
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.appsync.GraphQLApi("example", {
* authenticationType: "AWS_IAM",
* name: "example",
* introspectionConfig: "ENABLED",
* queryDepthLimit: 2,
* resolverCountLimit: 2,
* });
* ```
*
* ## Import
*
* Using `pulumi import`, import AppSync GraphQL API using the GraphQL API ID. For example:
*
* ```sh
* $ pulumi import aws:appsync/graphQLApi:GraphQLApi example 0123456789
* ```
*/
class GraphQLApi extends pulumi.CustomResource {
/**
* Get an existing GraphQLApi resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name, id, state, opts) {
return new GraphQLApi(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of GraphQLApi. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj) {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === GraphQLApi.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["additionalAuthenticationProviders"] = state?.additionalAuthenticationProviders;
resourceInputs["apiType"] = state?.apiType;
resourceInputs["arn"] = state?.arn;
resourceInputs["authenticationType"] = state?.authenticationType;
resourceInputs["enhancedMetricsConfig"] = state?.enhancedMetricsConfig;
resourceInputs["introspectionConfig"] = state?.introspectionConfig;
resourceInputs["lambdaAuthorizerConfig"] = state?.lambdaAuthorizerConfig;
resourceInputs["logConfig"] = state?.logConfig;
resourceInputs["mergedApiExecutionRoleArn"] = state?.mergedApiExecutionRoleArn;
resourceInputs["name"] = state?.name;
resourceInputs["openidConnectConfig"] = state?.openidConnectConfig;
resourceInputs["queryDepthLimit"] = state?.queryDepthLimit;
resourceInputs["region"] = state?.region;
resourceInputs["resolverCountLimit"] = state?.resolverCountLimit;
resourceInputs["schema"] = state?.schema;
resourceInputs["tags"] = state?.tags;
resourceInputs["tagsAll"] = state?.tagsAll;
resourceInputs["uris"] = state?.uris;
resourceInputs["userPoolConfig"] = state?.userPoolConfig;
resourceInputs["visibility"] = state?.visibility;
resourceInputs["xrayEnabled"] = state?.xrayEnabled;
}
else {
const args = argsOrState;
if (args?.authenticationType === undefined && !opts.urn) {
throw new Error("Missing required property 'authenticationType'");
}
resourceInputs["additionalAuthenticationProviders"] = args?.additionalAuthenticationProviders;
resourceInputs["apiType"] = args?.apiType;
resourceInputs["authenticationType"] = args?.authenticationType;
resourceInputs["enhancedMetricsConfig"] = args?.enhancedMetricsConfig;
resourceInputs["introspectionConfig"] = args?.introspectionConfig;
resourceInputs["lambdaAuthorizerConfig"] = args?.lambdaAuthorizerConfig;
resourceInputs["logConfig"] = args?.logConfig;
resourceInputs["mergedApiExecutionRoleArn"] = args?.mergedApiExecutionRoleArn;
resourceInputs["name"] = args?.name;
resourceInputs["openidConnectConfig"] = args?.openidConnectConfig;
resourceInputs["queryDepthLimit"] = args?.queryDepthLimit;
resourceInputs["region"] = args?.region;
resourceInputs["resolverCountLimit"] = args?.resolverCountLimit;
resourceInputs["schema"] = args?.schema;
resourceInputs["tags"] = args?.tags;
resourceInputs["userPoolConfig"] = args?.userPoolConfig;
resourceInputs["visibility"] = args?.visibility;
resourceInputs["xrayEnabled"] = args?.xrayEnabled;
resourceInputs["arn"] = undefined /*out*/;
resourceInputs["tagsAll"] = undefined /*out*/;
resourceInputs["uris"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(GraphQLApi.__pulumiType, name, resourceInputs, opts);
}
}
exports.GraphQLApi = GraphQLApi;
/** @internal */
GraphQLApi.__pulumiType = 'aws:appsync/graphQLApi:GraphQLApi';
//# sourceMappingURL=graphQLApi.js.map