UNPKG

@pulumi/aws

Version:

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

238 lines • 9.79 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.MetricStream = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Provides a CloudWatch Metric Stream resource. * * ## Example Usage * * ### Filters * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * // https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-metric-streams-trustpolicy.html * const streamsAssumeRole = aws.iam.getPolicyDocument({ * statements: [{ * effect: "Allow", * principals: [{ * type: "Service", * identifiers: ["streams.metrics.cloudwatch.amazonaws.com"], * }], * actions: ["sts:AssumeRole"], * }], * }); * const metricStreamToFirehoseRole = new aws.iam.Role("metric_stream_to_firehose", { * name: "metric_stream_to_firehose_role", * assumeRolePolicy: streamsAssumeRole.then(streamsAssumeRole => streamsAssumeRole.json), * }); * const bucket = new aws.s3.Bucket("bucket", {bucket: "metric-stream-test-bucket"}); * const firehoseAssumeRole = aws.iam.getPolicyDocument({ * statements: [{ * effect: "Allow", * principals: [{ * type: "Service", * identifiers: ["firehose.amazonaws.com"], * }], * actions: ["sts:AssumeRole"], * }], * }); * const firehoseToS3Role = new aws.iam.Role("firehose_to_s3", {assumeRolePolicy: firehoseAssumeRole.then(firehoseAssumeRole => firehoseAssumeRole.json)}); * const s3Stream = new aws.kinesis.FirehoseDeliveryStream("s3_stream", { * name: "metric-stream-test-stream", * destination: "extended_s3", * extendedS3Configuration: { * roleArn: firehoseToS3Role.arn, * bucketArn: bucket.arn, * }, * }); * const main = new aws.cloudwatch.MetricStream("main", { * name: "my-metric-stream", * roleArn: metricStreamToFirehoseRole.arn, * firehoseArn: s3Stream.arn, * outputFormat: "json", * includeFilters: [ * { * namespace: "AWS/EC2", * metricNames: [ * "CPUUtilization", * "NetworkOut", * ], * }, * { * namespace: "AWS/EBS", * metricNames: [], * }, * ], * }); * // https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-metric-streams-trustpolicy.html * const metricStreamToFirehose = aws.iam.getPolicyDocumentOutput({ * statements: [{ * effect: "Allow", * actions: [ * "firehose:PutRecord", * "firehose:PutRecordBatch", * ], * resources: [s3Stream.arn], * }], * }); * const metricStreamToFirehoseRolePolicy = new aws.iam.RolePolicy("metric_stream_to_firehose", { * name: "default", * role: metricStreamToFirehoseRole.id, * policy: metricStreamToFirehose.apply(metricStreamToFirehose => metricStreamToFirehose.json), * }); * const bucketAcl = new aws.s3.BucketAcl("bucket_acl", { * bucket: bucket.id, * acl: "private", * }); * const firehoseToS3 = aws.iam.getPolicyDocumentOutput({ * statements: [{ * effect: "Allow", * actions: [ * "s3:AbortMultipartUpload", * "s3:GetBucketLocation", * "s3:GetObject", * "s3:ListBucket", * "s3:ListBucketMultipartUploads", * "s3:PutObject", * ], * resources: [ * bucket.arn, * pulumi.interpolate`${bucket.arn}/*`, * ], * }], * }); * const firehoseToS3RolePolicy = new aws.iam.RolePolicy("firehose_to_s3", { * name: "default", * role: firehoseToS3Role.id, * policy: firehoseToS3.apply(firehoseToS3 => firehoseToS3.json), * }); * ``` * * ### Additional Statistics * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const main = new aws.cloudwatch.MetricStream("main", { * name: "my-metric-stream", * roleArn: metricStreamToFirehose.arn, * firehoseArn: s3Stream.arn, * outputFormat: "json", * statisticsConfigurations: [ * { * additionalStatistics: [ * "p1", * "tm99", * ], * includeMetrics: [{ * metricName: "CPUUtilization", * namespace: "AWS/EC2", * }], * }, * { * additionalStatistics: ["TS(50.5:)"], * includeMetrics: [{ * metricName: "CPUUtilization", * namespace: "AWS/EC2", * }], * }, * ], * }); * ``` * * ## Import * * Using `pulumi import`, import CloudWatch metric streams using the `name`. For example: * * ```sh * $ pulumi import aws:cloudwatch/metricStream:MetricStream sample sample-stream-name * ``` */ class MetricStream extends pulumi.CustomResource { /** * Get an existing MetricStream 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 MetricStream(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * Returns true if the given object is an instance of MetricStream. 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'] === MetricStream.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["arn"] = state ? state.arn : undefined; resourceInputs["creationDate"] = state ? state.creationDate : undefined; resourceInputs["excludeFilters"] = state ? state.excludeFilters : undefined; resourceInputs["firehoseArn"] = state ? state.firehoseArn : undefined; resourceInputs["includeFilters"] = state ? state.includeFilters : undefined; resourceInputs["includeLinkedAccountsMetrics"] = state ? state.includeLinkedAccountsMetrics : undefined; resourceInputs["lastUpdateDate"] = state ? state.lastUpdateDate : undefined; resourceInputs["name"] = state ? state.name : undefined; resourceInputs["namePrefix"] = state ? state.namePrefix : undefined; resourceInputs["outputFormat"] = state ? state.outputFormat : undefined; resourceInputs["region"] = state ? state.region : undefined; resourceInputs["roleArn"] = state ? state.roleArn : undefined; resourceInputs["state"] = state ? state.state : undefined; resourceInputs["statisticsConfigurations"] = state ? state.statisticsConfigurations : undefined; resourceInputs["tags"] = state ? state.tags : undefined; resourceInputs["tagsAll"] = state ? state.tagsAll : undefined; } else { const args = argsOrState; if ((!args || args.firehoseArn === undefined) && !opts.urn) { throw new Error("Missing required property 'firehoseArn'"); } if ((!args || args.outputFormat === undefined) && !opts.urn) { throw new Error("Missing required property 'outputFormat'"); } if ((!args || args.roleArn === undefined) && !opts.urn) { throw new Error("Missing required property 'roleArn'"); } resourceInputs["excludeFilters"] = args ? args.excludeFilters : undefined; resourceInputs["firehoseArn"] = args ? args.firehoseArn : undefined; resourceInputs["includeFilters"] = args ? args.includeFilters : undefined; resourceInputs["includeLinkedAccountsMetrics"] = args ? args.includeLinkedAccountsMetrics : undefined; resourceInputs["name"] = args ? args.name : undefined; resourceInputs["namePrefix"] = args ? args.namePrefix : undefined; resourceInputs["outputFormat"] = args ? args.outputFormat : undefined; resourceInputs["region"] = args ? args.region : undefined; resourceInputs["roleArn"] = args ? args.roleArn : undefined; resourceInputs["statisticsConfigurations"] = args ? args.statisticsConfigurations : undefined; resourceInputs["tags"] = args ? args.tags : undefined; resourceInputs["arn"] = undefined /*out*/; resourceInputs["creationDate"] = undefined /*out*/; resourceInputs["lastUpdateDate"] = undefined /*out*/; resourceInputs["state"] = undefined /*out*/; resourceInputs["tagsAll"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(MetricStream.__pulumiType, name, resourceInputs, opts); } } exports.MetricStream = MetricStream; /** @internal */ MetricStream.__pulumiType = 'aws:cloudwatch/metricStream:MetricStream'; //# sourceMappingURL=metricStream.js.map