@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
149 lines • 5.92 kB
JavaScript
;
// *** 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.DataSource = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Provides an AppSync Data Source.
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const exampleTable = new aws.dynamodb.Table("example", {
* name: "example",
* readCapacity: 1,
* writeCapacity: 1,
* hashKey: "UserId",
* attributes: [{
* name: "UserId",
* type: "S",
* }],
* });
* const assumeRole = aws.iam.getPolicyDocument({
* statements: [{
* effect: "Allow",
* principals: [{
* type: "Service",
* identifiers: ["appsync.amazonaws.com"],
* }],
* actions: ["sts:AssumeRole"],
* }],
* });
* const exampleRole = new aws.iam.Role("example", {
* name: "example",
* assumeRolePolicy: assumeRole.then(assumeRole => assumeRole.json),
* });
* const example = aws.iam.getPolicyDocumentOutput({
* statements: [{
* effect: "Allow",
* actions: ["dynamodb:*"],
* resources: [exampleTable.arn],
* }],
* });
* const exampleRolePolicy = new aws.iam.RolePolicy("example", {
* name: "example",
* role: exampleRole.id,
* policy: example.apply(example => example.json),
* });
* const exampleGraphQLApi = new aws.appsync.GraphQLApi("example", {
* authenticationType: "API_KEY",
* name: "my_appsync_example",
* });
* const exampleDataSource = new aws.appsync.DataSource("example", {
* apiId: exampleGraphQLApi.id,
* name: "my_appsync_example",
* serviceRoleArn: exampleRole.arn,
* type: "AMAZON_DYNAMODB",
* dynamodbConfig: {
* tableName: exampleTable.name,
* },
* });
* ```
*
* ## Import
*
* Using `pulumi import`, import `aws_appsync_datasource` using the `api_id`, a hyphen, and `name`. For example:
*
* ```sh
* $ pulumi import aws:appsync/dataSource:DataSource example abcdef123456-example
* ```
*/
class DataSource extends pulumi.CustomResource {
/**
* Get an existing DataSource 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 DataSource(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of DataSource. 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'] === DataSource.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["apiId"] = state?.apiId;
resourceInputs["arn"] = state?.arn;
resourceInputs["description"] = state?.description;
resourceInputs["dynamodbConfig"] = state?.dynamodbConfig;
resourceInputs["elasticsearchConfig"] = state?.elasticsearchConfig;
resourceInputs["eventBridgeConfig"] = state?.eventBridgeConfig;
resourceInputs["httpConfig"] = state?.httpConfig;
resourceInputs["lambdaConfig"] = state?.lambdaConfig;
resourceInputs["name"] = state?.name;
resourceInputs["opensearchserviceConfig"] = state?.opensearchserviceConfig;
resourceInputs["region"] = state?.region;
resourceInputs["relationalDatabaseConfig"] = state?.relationalDatabaseConfig;
resourceInputs["serviceRoleArn"] = state?.serviceRoleArn;
resourceInputs["type"] = state?.type;
}
else {
const args = argsOrState;
if (args?.apiId === undefined && !opts.urn) {
throw new Error("Missing required property 'apiId'");
}
if (args?.type === undefined && !opts.urn) {
throw new Error("Missing required property 'type'");
}
resourceInputs["apiId"] = args?.apiId;
resourceInputs["description"] = args?.description;
resourceInputs["dynamodbConfig"] = args?.dynamodbConfig;
resourceInputs["elasticsearchConfig"] = args?.elasticsearchConfig;
resourceInputs["eventBridgeConfig"] = args?.eventBridgeConfig;
resourceInputs["httpConfig"] = args?.httpConfig;
resourceInputs["lambdaConfig"] = args?.lambdaConfig;
resourceInputs["name"] = args?.name;
resourceInputs["opensearchserviceConfig"] = args?.opensearchserviceConfig;
resourceInputs["region"] = args?.region;
resourceInputs["relationalDatabaseConfig"] = args?.relationalDatabaseConfig;
resourceInputs["serviceRoleArn"] = args?.serviceRoleArn;
resourceInputs["type"] = args?.type;
resourceInputs["arn"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(DataSource.__pulumiType, name, resourceInputs, opts);
}
}
exports.DataSource = DataSource;
/** @internal */
DataSource.__pulumiType = 'aws:appsync/dataSource:DataSource';
//# sourceMappingURL=dataSource.js.map