UNPKG

@pulumi/aws

Version:

A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.

260 lines • 9.91 kB
"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.Domain = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Manages an AWS Elasticsearch Domain. * * ## Example Usage * * ### Basic Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.elasticsearch.Domain("example", { * domainName: "example", * elasticsearchVersion: "7.10", * clusterConfig: { * instanceType: "r4.large.elasticsearch", * }, * tags: { * Domain: "TestDomain", * }, * }); * ``` * * ### Access Policy * * > See also: `aws.elasticsearch.DomainPolicy` resource * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const config = new pulumi.Config(); * const domain = config.get("domain") || "tf-test"; * const current = aws.getRegion({}); * const currentGetCallerIdentity = aws.getCallerIdentity({}); * const example = new aws.elasticsearch.Domain("example", { * domainName: domain, * accessPolicies: Promise.all([current, currentGetCallerIdentity]).then(([current, currentGetCallerIdentity]) => `{ * \"Version\": \"2012-10-17\", * \"Statement\": [ * { * \"Action\": \"es:*\", * \"Principal\": \"*\", * \"Effect\": \"Allow\", * \"Resource\": \"arn:aws:es:${current.region}:${currentGetCallerIdentity.accountId}:domain/${domain}/*\", * \"Condition\": { * \"IpAddress\": {\"aws:SourceIp\": [\"66.193.100.22/32\"]} * } * } * ] * } * `), * }); * ``` * * ### Log Publishing to CloudWatch Logs * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const exampleLogGroup = new aws.cloudwatch.LogGroup("example", {name: "example"}); * const example = aws.iam.getPolicyDocument({ * statements: [{ * effect: "Allow", * principals: [{ * type: "Service", * identifiers: ["es.amazonaws.com"], * }], * actions: [ * "logs:PutLogEvents", * "logs:PutLogEventsBatch", * "logs:CreateLogStream", * ], * resources: ["arn:aws:logs:*"], * }], * }); * const exampleLogResourcePolicy = new aws.cloudwatch.LogResourcePolicy("example", { * policyName: "example", * policyDocument: example.then(example => example.json), * }); * const exampleDomain = new aws.elasticsearch.Domain("example", {logPublishingOptions: [{ * cloudwatchLogGroupArn: exampleLogGroup.arn, * logType: "INDEX_SLOW_LOGS", * }]}); * ``` * * ### VPC based ES * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const config = new pulumi.Config(); * const vpc = config.requireObject<any>("vpc"); * const domain = config.get("domain") || "tf-test"; * const selected = aws.ec2.getVpc({ * tags: { * Name: vpc, * }, * }); * const selectedGetSubnets = selected.then(selected => aws.ec2.getSubnets({ * filters: [{ * name: "vpc-id", * values: [selected.id], * }], * tags: { * Tier: "private", * }, * })); * const current = aws.getRegion({}); * const currentGetCallerIdentity = aws.getCallerIdentity({}); * const es = new aws.ec2.SecurityGroup("es", { * name: `${vpc}-elasticsearch-${domain}`, * description: "Managed by Pulumi", * vpcId: selected.then(selected => selected.id), * ingress: [{ * fromPort: 443, * toPort: 443, * protocol: "tcp", * cidrBlocks: [selected.then(selected => selected.cidrBlock)], * }], * }); * const esServiceLinkedRole = new aws.iam.ServiceLinkedRole("es", {awsServiceName: "opensearchservice.amazonaws.com"}); * const esDomain = new aws.elasticsearch.Domain("es", { * domainName: domain, * elasticsearchVersion: "6.3", * clusterConfig: { * instanceType: "m4.large.elasticsearch", * zoneAwarenessEnabled: true, * }, * vpcOptions: { * subnetIds: [ * selectedGetSubnets.then(selectedGetSubnets => selectedGetSubnets.ids?.[0]), * selectedGetSubnets.then(selectedGetSubnets => selectedGetSubnets.ids?.[1]), * ], * securityGroupIds: [es.id], * }, * advancedOptions: { * "rest.action.multi.allow_explicit_index": "true", * }, * accessPolicies: Promise.all([current, currentGetCallerIdentity]).then(([current, currentGetCallerIdentity]) => `{ * \t\"Version\": \"2012-10-17\", * \t\"Statement\": [ * \t\t{ * \t\t\t\"Action\": \"es:*\", * \t\t\t\"Principal\": \"*\", * \t\t\t\"Effect\": \"Allow\", * \t\t\t\"Resource\": \"arn:aws:es:${current.region}:${currentGetCallerIdentity.accountId}:domain/${domain}/*\" * \t\t} * \t] * } * `), * tags: { * Domain: "TestDomain", * }, * }, { * dependsOn: [esServiceLinkedRole], * }); * ``` * * ## Import * * Using `pulumi import`, import Elasticsearch domains using the `domain_name`. For example: * * ```sh * $ pulumi import aws:elasticsearch/domain:Domain example domain_name * ``` */ class Domain extends pulumi.CustomResource { /** * Get an existing Domain 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 Domain(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of Domain. 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'] === Domain.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["accessPolicies"] = state?.accessPolicies; resourceInputs["advancedOptions"] = state?.advancedOptions; resourceInputs["advancedSecurityOptions"] = state?.advancedSecurityOptions; resourceInputs["arn"] = state?.arn; resourceInputs["autoTuneOptions"] = state?.autoTuneOptions; resourceInputs["clusterConfig"] = state?.clusterConfig; resourceInputs["cognitoOptions"] = state?.cognitoOptions; resourceInputs["domainEndpointOptions"] = state?.domainEndpointOptions; resourceInputs["domainId"] = state?.domainId; resourceInputs["domainName"] = state?.domainName; resourceInputs["ebsOptions"] = state?.ebsOptions; resourceInputs["elasticsearchVersion"] = state?.elasticsearchVersion; resourceInputs["encryptAtRest"] = state?.encryptAtRest; resourceInputs["endpoint"] = state?.endpoint; resourceInputs["kibanaEndpoint"] = state?.kibanaEndpoint; resourceInputs["logPublishingOptions"] = state?.logPublishingOptions; resourceInputs["nodeToNodeEncryption"] = state?.nodeToNodeEncryption; resourceInputs["region"] = state?.region; resourceInputs["snapshotOptions"] = state?.snapshotOptions; resourceInputs["tags"] = state?.tags; resourceInputs["tagsAll"] = state?.tagsAll; resourceInputs["vpcOptions"] = state?.vpcOptions; } else { const args = argsOrState; resourceInputs["accessPolicies"] = args?.accessPolicies; resourceInputs["advancedOptions"] = args?.advancedOptions; resourceInputs["advancedSecurityOptions"] = args?.advancedSecurityOptions; resourceInputs["autoTuneOptions"] = args?.autoTuneOptions; resourceInputs["clusterConfig"] = args?.clusterConfig; resourceInputs["cognitoOptions"] = args?.cognitoOptions; resourceInputs["domainEndpointOptions"] = args?.domainEndpointOptions; resourceInputs["domainName"] = args?.domainName; resourceInputs["ebsOptions"] = args?.ebsOptions; resourceInputs["elasticsearchVersion"] = args?.elasticsearchVersion; resourceInputs["encryptAtRest"] = args?.encryptAtRest; resourceInputs["logPublishingOptions"] = args?.logPublishingOptions; resourceInputs["nodeToNodeEncryption"] = args?.nodeToNodeEncryption; resourceInputs["region"] = args?.region; resourceInputs["snapshotOptions"] = args?.snapshotOptions; resourceInputs["tags"] = args?.tags; resourceInputs["vpcOptions"] = args?.vpcOptions; resourceInputs["arn"] = undefined /*out*/; resourceInputs["domainId"] = undefined /*out*/; resourceInputs["endpoint"] = undefined /*out*/; resourceInputs["kibanaEndpoint"] = undefined /*out*/; resourceInputs["tagsAll"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(Domain.__pulumiType, name, resourceInputs, opts); } } exports.Domain = Domain; /** @internal */ Domain.__pulumiType = 'aws:elasticsearch/domain:Domain'; //# sourceMappingURL=domain.js.map