UNPKG

@pulumi/aws

Version:

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

260 lines • 10.6 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]) => `{ * "Version": "2012-10-17", * "Statement": [ * { * "Action": "es:*", * "Principal": "*", * "Effect": "Allow", * "Resource": "arn:aws:es:${current.region}:${currentGetCallerIdentity.accountId}:domain/${domain}/*" * } * ] * } * `), * 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, Object.assign(Object.assign({}, 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 ? state.accessPolicies : undefined; resourceInputs["advancedOptions"] = state ? state.advancedOptions : undefined; resourceInputs["advancedSecurityOptions"] = state ? state.advancedSecurityOptions : undefined; resourceInputs["arn"] = state ? state.arn : undefined; resourceInputs["autoTuneOptions"] = state ? state.autoTuneOptions : undefined; resourceInputs["clusterConfig"] = state ? state.clusterConfig : undefined; resourceInputs["cognitoOptions"] = state ? state.cognitoOptions : undefined; resourceInputs["domainEndpointOptions"] = state ? state.domainEndpointOptions : undefined; resourceInputs["domainId"] = state ? state.domainId : undefined; resourceInputs["domainName"] = state ? state.domainName : undefined; resourceInputs["ebsOptions"] = state ? state.ebsOptions : undefined; resourceInputs["elasticsearchVersion"] = state ? state.elasticsearchVersion : undefined; resourceInputs["encryptAtRest"] = state ? state.encryptAtRest : undefined; resourceInputs["endpoint"] = state ? state.endpoint : undefined; resourceInputs["kibanaEndpoint"] = state ? state.kibanaEndpoint : undefined; resourceInputs["logPublishingOptions"] = state ? state.logPublishingOptions : undefined; resourceInputs["nodeToNodeEncryption"] = state ? state.nodeToNodeEncryption : undefined; resourceInputs["region"] = state ? state.region : undefined; resourceInputs["snapshotOptions"] = state ? state.snapshotOptions : undefined; resourceInputs["tags"] = state ? state.tags : undefined; resourceInputs["tagsAll"] = state ? state.tagsAll : undefined; resourceInputs["vpcOptions"] = state ? state.vpcOptions : undefined; } else { const args = argsOrState; resourceInputs["accessPolicies"] = args ? args.accessPolicies : undefined; resourceInputs["advancedOptions"] = args ? args.advancedOptions : undefined; resourceInputs["advancedSecurityOptions"] = args ? args.advancedSecurityOptions : undefined; resourceInputs["autoTuneOptions"] = args ? args.autoTuneOptions : undefined; resourceInputs["clusterConfig"] = args ? args.clusterConfig : undefined; resourceInputs["cognitoOptions"] = args ? args.cognitoOptions : undefined; resourceInputs["domainEndpointOptions"] = args ? args.domainEndpointOptions : undefined; resourceInputs["domainName"] = args ? args.domainName : undefined; resourceInputs["ebsOptions"] = args ? args.ebsOptions : undefined; resourceInputs["elasticsearchVersion"] = args ? args.elasticsearchVersion : undefined; resourceInputs["encryptAtRest"] = args ? args.encryptAtRest : undefined; resourceInputs["logPublishingOptions"] = args ? args.logPublishingOptions : undefined; resourceInputs["nodeToNodeEncryption"] = args ? args.nodeToNodeEncryption : undefined; resourceInputs["region"] = args ? args.region : undefined; resourceInputs["snapshotOptions"] = args ? args.snapshotOptions : undefined; resourceInputs["tags"] = args ? args.tags : undefined; resourceInputs["vpcOptions"] = args ? args.vpcOptions : undefined; 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