@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
224 lines • 11.1 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.Branch = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Provides an Amplify Branch resource.
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.amplify.App("example", {name: "app"});
* const master = new aws.amplify.Branch("master", {
* appId: example.id,
* branchName: "master",
* framework: "React",
* stage: "PRODUCTION",
* environmentVariables: {
* REACT_APP_API_SERVER: "https://api.example.com",
* },
* });
* ```
*
* ### Basic Authentication
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
* import * as std from "@pulumi/std";
*
* const example = new aws.amplify.App("example", {name: "app"});
* const master = new aws.amplify.Branch("master", {
* appId: example.id,
* branchName: "master",
* enableBasicAuth: true,
* basicAuthCredentials: std.base64encode({
* input: "username:password",
* }).then(invoke => invoke.result),
* });
* ```
*
* ### Notifications
*
* Amplify Console uses EventBridge (formerly known as CloudWatch Events) and SNS for email notifications. To implement the same functionality, you need to set `enableNotification` in a `aws.amplify.Branch` resource, as well as creating an EventBridge Rule, an SNS topic, and SNS subscriptions.
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.amplify.App("example", {name: "app"});
* const master = new aws.amplify.Branch("master", {
* appId: example.id,
* branchName: "master",
* enableNotification: true,
* });
* // EventBridge Rule for Amplify notifications
* const amplifyAppMasterEventRule = new aws.cloudwatch.EventRule("amplify_app_master", {
* name: pulumi.interpolate`amplify-${app.id}-${master.branchName}-branch-notification`,
* description: pulumi.interpolate`AWS Amplify build notifications for : App: ${app.id} Branch: ${master.branchName}`,
* eventPattern: pulumi.jsonStringify({
* detail: {
* appId: [example.id],
* branchName: [master.branchName],
* jobStatus: [
* "SUCCEED",
* "FAILED",
* "STARTED",
* ],
* },
* "detail-type": ["Amplify Deployment Status Change"],
* source: ["aws.amplify"],
* }),
* });
* // SNS Topic for Amplify notifications
* const amplifyAppMasterTopic = new aws.sns.Topic("amplify_app_master", {name: pulumi.interpolate`amplify-${app.id}_${master.branchName}`});
* const amplifyAppMasterEventTarget = new aws.cloudwatch.EventTarget("amplify_app_master", {
* rule: amplifyAppMasterEventRule.name,
* targetId: master.branchName,
* arn: amplifyAppMasterTopic.arn,
* inputTransformer: {
* inputPaths: {
* jobId: "$.detail.jobId",
* appId: "$.detail.appId",
* region: "$.region",
* branch: "$.detail.branchName",
* status: "$.detail.jobStatus",
* },
* inputTemplate: "\"Build notification from the AWS Amplify Console for app: https://<branch>.<appId>.amplifyapp.com/. Your build status is <status>. Go to https://console.aws.amazon.com/amplify/home?region=<region>#<appId>/<branch>/<jobId> to view details on your build. \"",
* },
* });
* const amplifyAppMaster = aws.iam.getPolicyDocumentOutput({
* statements: [{
* sid: pulumi.interpolate`Allow_Publish_Events ${master.arn}`,
* effect: "Allow",
* actions: ["SNS:Publish"],
* principals: [{
* type: "Service",
* identifiers: ["events.amazonaws.com"],
* }],
* resources: [amplifyAppMasterTopic.arn],
* }],
* });
* const amplifyAppMasterTopicPolicy = new aws.sns.TopicPolicy("amplify_app_master", {
* arn: amplifyAppMasterTopic.arn,
* policy: amplifyAppMaster.apply(amplifyAppMaster => amplifyAppMaster.json),
* });
* const _this = new aws.sns.TopicSubscription("this", {
* topic: amplifyAppMasterTopic.arn,
* protocol: "email",
* endpoint: "user@acme.com",
* });
* ```
*
* ## Import
*
* Using `pulumi import`, import Amplify branch using `app_id` and `branch_name`. For example:
*
* ```sh
* $ pulumi import aws:amplify/branch:Branch master d2ypk4k47z8u6/master
* ```
*/
class Branch extends pulumi.CustomResource {
/**
* Get an existing Branch 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 Branch(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of Branch. 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'] === Branch.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["appId"] = state ? state.appId : undefined;
resourceInputs["arn"] = state ? state.arn : undefined;
resourceInputs["associatedResources"] = state ? state.associatedResources : undefined;
resourceInputs["backendEnvironmentArn"] = state ? state.backendEnvironmentArn : undefined;
resourceInputs["basicAuthCredentials"] = state ? state.basicAuthCredentials : undefined;
resourceInputs["branchName"] = state ? state.branchName : undefined;
resourceInputs["customDomains"] = state ? state.customDomains : undefined;
resourceInputs["description"] = state ? state.description : undefined;
resourceInputs["destinationBranch"] = state ? state.destinationBranch : undefined;
resourceInputs["displayName"] = state ? state.displayName : undefined;
resourceInputs["enableAutoBuild"] = state ? state.enableAutoBuild : undefined;
resourceInputs["enableBasicAuth"] = state ? state.enableBasicAuth : undefined;
resourceInputs["enableNotification"] = state ? state.enableNotification : undefined;
resourceInputs["enablePerformanceMode"] = state ? state.enablePerformanceMode : undefined;
resourceInputs["enablePullRequestPreview"] = state ? state.enablePullRequestPreview : undefined;
resourceInputs["enableSkewProtection"] = state ? state.enableSkewProtection : undefined;
resourceInputs["environmentVariables"] = state ? state.environmentVariables : undefined;
resourceInputs["framework"] = state ? state.framework : undefined;
resourceInputs["pullRequestEnvironmentName"] = state ? state.pullRequestEnvironmentName : undefined;
resourceInputs["region"] = state ? state.region : undefined;
resourceInputs["sourceBranch"] = state ? state.sourceBranch : undefined;
resourceInputs["stage"] = state ? state.stage : undefined;
resourceInputs["tags"] = state ? state.tags : undefined;
resourceInputs["tagsAll"] = state ? state.tagsAll : undefined;
resourceInputs["ttl"] = state ? state.ttl : undefined;
}
else {
const args = argsOrState;
if ((!args || args.appId === undefined) && !opts.urn) {
throw new Error("Missing required property 'appId'");
}
if ((!args || args.branchName === undefined) && !opts.urn) {
throw new Error("Missing required property 'branchName'");
}
resourceInputs["appId"] = args ? args.appId : undefined;
resourceInputs["backendEnvironmentArn"] = args ? args.backendEnvironmentArn : undefined;
resourceInputs["basicAuthCredentials"] = (args === null || args === void 0 ? void 0 : args.basicAuthCredentials) ? pulumi.secret(args.basicAuthCredentials) : undefined;
resourceInputs["branchName"] = args ? args.branchName : undefined;
resourceInputs["description"] = args ? args.description : undefined;
resourceInputs["displayName"] = args ? args.displayName : undefined;
resourceInputs["enableAutoBuild"] = args ? args.enableAutoBuild : undefined;
resourceInputs["enableBasicAuth"] = args ? args.enableBasicAuth : undefined;
resourceInputs["enableNotification"] = args ? args.enableNotification : undefined;
resourceInputs["enablePerformanceMode"] = args ? args.enablePerformanceMode : undefined;
resourceInputs["enablePullRequestPreview"] = args ? args.enablePullRequestPreview : undefined;
resourceInputs["enableSkewProtection"] = args ? args.enableSkewProtection : undefined;
resourceInputs["environmentVariables"] = args ? args.environmentVariables : undefined;
resourceInputs["framework"] = args ? args.framework : undefined;
resourceInputs["pullRequestEnvironmentName"] = args ? args.pullRequestEnvironmentName : undefined;
resourceInputs["region"] = args ? args.region : undefined;
resourceInputs["stage"] = args ? args.stage : undefined;
resourceInputs["tags"] = args ? args.tags : undefined;
resourceInputs["ttl"] = args ? args.ttl : undefined;
resourceInputs["arn"] = undefined /*out*/;
resourceInputs["associatedResources"] = undefined /*out*/;
resourceInputs["customDomains"] = undefined /*out*/;
resourceInputs["destinationBranch"] = undefined /*out*/;
resourceInputs["sourceBranch"] = undefined /*out*/;
resourceInputs["tagsAll"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
const secretOpts = { additionalSecretOutputs: ["basicAuthCredentials"] };
opts = pulumi.mergeOptions(opts, secretOpts);
super(Branch.__pulumiType, name, resourceInputs, opts);
}
}
exports.Branch = Branch;
/** @internal */
Branch.__pulumiType = 'aws:amplify/branch:Branch';
//# sourceMappingURL=branch.js.map