@pulumi/aws-native
Version:
The Pulumi AWS Cloud Control Provider enables you to build, deploy, and manage [any AWS resource that's supported by the AWS Cloud Control API](https://github.com/pulumi/pulumi-aws-native/blob/master/provider/cmd/pulumi-gen-aws-native/supported-types.txt)
200 lines • 8.88 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.Canary = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Resource Type definition for AWS::Synthetics::Canary
*
* ## Example Usage
* ### Example
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws_native from "@pulumi/aws-native";
*
* const syntheticsCanary = new aws_native.synthetics.Canary("syntheticsCanary", {
* name: "samplecanary",
* executionRoleArn: "arn:aws:iam::123456789012:role/my-lambda-execution-role-to-run-canary",
* code: {
* handler: "pageLoadBlueprint.handler",
* s3Bucket: "aws-synthetics-code-myaccount-canary1",
* s3Key: "my-script-location",
* },
* artifactS3Location: "s3://my-results-bucket",
* runtimeVersion: "syn-nodejs-puppeteer-3.3",
* schedule: {
* expression: "rate(1 minute)",
* durationInSeconds: "3600",
* },
* runConfig: {
* timeoutInSeconds: 60,
* },
* failureRetentionPeriod: 30,
* successRetentionPeriod: 30,
* tags: [{
* key: "key00AtCreate",
* value: "value001AtCreate",
* }],
* startCanaryAfterCreation: true,
* });
*
* ```
* ### Example
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws_native from "@pulumi/aws-native";
*
* const syntheticsCanary = new aws_native.synthetics.Canary("syntheticsCanary", {
* name: "samplecanary",
* executionRoleArn: "arn:aws:iam::123456789012:role/my-lambda-execution-role-to-run-canary",
* code: {
* handler: "pageLoadBlueprint.handler",
* script: `var synthetics = require('Synthetics');
* const log = require('SyntheticsLogger');
* const pageLoadBlueprint = async function () {
* // INSERT URL here
* const URL = "https://amazon.com";
*
* let page = await synthetics.getPage();
* const response = await page.goto(URL, {waitUntil: 'domcontentloaded', timeout: 30000});
* //Wait for page to render.
* //Increase or decrease wait time based on endpoint being monitored.
* await page.waitFor(15000);
* await synthetics.takeScreenshot('loaded', 'loaded');
* let pageTitle = await page.title();
* log.info('Page title: ' + pageTitle);
* if (response.status() !== 200) {
* throw "Failed to load page!";
* }
* };
*
* exports.handler = async () => {
* return await pageLoadBlueprint();
* };
* `,
* },
* artifactS3Location: "s3://my-results-bucket",
* runtimeVersion: "syn-nodejs-puppeteer-3.3",
* schedule: {
* expression: "rate(1 minute)",
* durationInSeconds: "3600",
* },
* runConfig: {
* timeoutInSeconds: 60,
* },
* failureRetentionPeriod: 30,
* successRetentionPeriod: 30,
* tags: [{
* key: "key00AtCreate",
* value: "value001AtCreate",
* }],
* startCanaryAfterCreation: false,
* });
*
* ```
*/
class Canary extends pulumi.CustomResource {
/**
* Get an existing Canary 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 opts Optional settings to control the behavior of the CustomResource.
*/
static get(name, id, opts) {
return new Canary(name, undefined, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of Canary. 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'] === Canary.__pulumiType;
}
/**
* Create a Canary resource with the given unique name, arguments, and options.
*
* @param name The _unique_ name of the resource.
* @param args The arguments to use to populate this resource's properties.
* @param opts A bag of options that control this resource's behavior.
*/
constructor(name, args, opts) {
let resourceInputs = {};
opts = opts || {};
if (!opts.id) {
if ((!args || args.artifactS3Location === undefined) && !opts.urn) {
throw new Error("Missing required property 'artifactS3Location'");
}
if ((!args || args.code === undefined) && !opts.urn) {
throw new Error("Missing required property 'code'");
}
if ((!args || args.executionRoleArn === undefined) && !opts.urn) {
throw new Error("Missing required property 'executionRoleArn'");
}
if ((!args || args.runtimeVersion === undefined) && !opts.urn) {
throw new Error("Missing required property 'runtimeVersion'");
}
if ((!args || args.schedule === undefined) && !opts.urn) {
throw new Error("Missing required property 'schedule'");
}
resourceInputs["artifactConfig"] = args ? args.artifactConfig : undefined;
resourceInputs["artifactS3Location"] = args ? args.artifactS3Location : undefined;
resourceInputs["code"] = args ? args.code : undefined;
resourceInputs["deleteLambdaResourcesOnCanaryDeletion"] = args ? args.deleteLambdaResourcesOnCanaryDeletion : undefined;
resourceInputs["dryRunAndUpdate"] = args ? args.dryRunAndUpdate : undefined;
resourceInputs["executionRoleArn"] = args ? args.executionRoleArn : undefined;
resourceInputs["failureRetentionPeriod"] = args ? args.failureRetentionPeriod : undefined;
resourceInputs["name"] = args ? args.name : undefined;
resourceInputs["provisionedResourceCleanup"] = args ? args.provisionedResourceCleanup : undefined;
resourceInputs["resourcesToReplicateTags"] = args ? args.resourcesToReplicateTags : undefined;
resourceInputs["runConfig"] = args ? args.runConfig : undefined;
resourceInputs["runtimeVersion"] = args ? args.runtimeVersion : undefined;
resourceInputs["schedule"] = args ? args.schedule : undefined;
resourceInputs["startCanaryAfterCreation"] = args ? args.startCanaryAfterCreation : undefined;
resourceInputs["successRetentionPeriod"] = args ? args.successRetentionPeriod : undefined;
resourceInputs["tags"] = args ? args.tags : undefined;
resourceInputs["visualReference"] = args ? args.visualReference : undefined;
resourceInputs["vpcConfig"] = args ? args.vpcConfig : undefined;
resourceInputs["awsId"] = undefined /*out*/;
resourceInputs["state"] = undefined /*out*/;
}
else {
resourceInputs["artifactConfig"] = undefined /*out*/;
resourceInputs["artifactS3Location"] = undefined /*out*/;
resourceInputs["awsId"] = undefined /*out*/;
resourceInputs["code"] = undefined /*out*/;
resourceInputs["deleteLambdaResourcesOnCanaryDeletion"] = undefined /*out*/;
resourceInputs["dryRunAndUpdate"] = undefined /*out*/;
resourceInputs["executionRoleArn"] = undefined /*out*/;
resourceInputs["failureRetentionPeriod"] = undefined /*out*/;
resourceInputs["name"] = undefined /*out*/;
resourceInputs["provisionedResourceCleanup"] = undefined /*out*/;
resourceInputs["resourcesToReplicateTags"] = undefined /*out*/;
resourceInputs["runConfig"] = undefined /*out*/;
resourceInputs["runtimeVersion"] = undefined /*out*/;
resourceInputs["schedule"] = undefined /*out*/;
resourceInputs["startCanaryAfterCreation"] = undefined /*out*/;
resourceInputs["state"] = undefined /*out*/;
resourceInputs["successRetentionPeriod"] = undefined /*out*/;
resourceInputs["tags"] = undefined /*out*/;
resourceInputs["visualReference"] = undefined /*out*/;
resourceInputs["vpcConfig"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
const replaceOnChanges = { replaceOnChanges: ["name"] };
opts = pulumi.mergeOptions(opts, replaceOnChanges);
super(Canary.__pulumiType, name, resourceInputs, opts);
}
}
exports.Canary = Canary;
/** @internal */
Canary.__pulumiType = 'aws-native:synthetics:Canary';
//# sourceMappingURL=canary.js.map