UNPKG

@pulumi/aws

Version:

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

238 lines • 9.22 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, { ...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?.arn; resourceInputs["creationDate"] = state?.creationDate; resourceInputs["excludeFilters"] = state?.excludeFilters; resourceInputs["firehoseArn"] = state?.firehoseArn; resourceInputs["includeFilters"] = state?.includeFilters; resourceInputs["includeLinkedAccountsMetrics"] = state?.includeLinkedAccountsMetrics; resourceInputs["lastUpdateDate"] = state?.lastUpdateDate; resourceInputs["name"] = state?.name; resourceInputs["namePrefix"] = state?.namePrefix; resourceInputs["outputFormat"] = state?.outputFormat; resourceInputs["region"] = state?.region; resourceInputs["roleArn"] = state?.roleArn; resourceInputs["state"] = state?.state; resourceInputs["statisticsConfigurations"] = state?.statisticsConfigurations; resourceInputs["tags"] = state?.tags; resourceInputs["tagsAll"] = state?.tagsAll; } else { const args = argsOrState; if (args?.firehoseArn === undefined && !opts.urn) { throw new Error("Missing required property 'firehoseArn'"); } if (args?.outputFormat === undefined && !opts.urn) { throw new Error("Missing required property 'outputFormat'"); } if (args?.roleArn === undefined && !opts.urn) { throw new Error("Missing required property 'roleArn'"); } resourceInputs["excludeFilters"] = args?.excludeFilters; resourceInputs["firehoseArn"] = args?.firehoseArn; resourceInputs["includeFilters"] = args?.includeFilters; resourceInputs["includeLinkedAccountsMetrics"] = args?.includeLinkedAccountsMetrics; resourceInputs["name"] = args?.name; resourceInputs["namePrefix"] = args?.namePrefix; resourceInputs["outputFormat"] = args?.outputFormat; resourceInputs["region"] = args?.region; resourceInputs["roleArn"] = args?.roleArn; resourceInputs["statisticsConfigurations"] = args?.statisticsConfigurations; resourceInputs["tags"] = args?.tags; 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