UNPKG

@pulumi/aws

Version:

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

282 lines • 10.8 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.App = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Provides an Amplify App resource, a fullstack serverless app hosted on the [AWS Amplify Console](https://docs.aws.amazon.com/amplify/latest/userguide/welcome.html). * * > **Note:** When you create/update an Amplify App from the provider, you may end up with the error "BadRequestException: You should at least provide one valid token" because of authentication issues. See the section "Repository with Tokens" below. * * ## Example Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.amplify.App("example", { * name: "example", * repository: "https://github.com/example/app", * buildSpec: `version: 0.1 * frontend: * phases: * preBuild: * commands: * - yarn install * build: * commands: * - yarn run build * artifacts: * baseDirectory: build * files: * - '**&#47;*' * cache: * paths: * - node_modules/**&#47;* * `, * customRules: [{ * source: "/<*>", * status: "404", * target: "/index.html", * }], * environmentVariables: { * ENV: "test", * }, * }); * ``` * * ### Repository with Tokens * * If you create a new Amplify App with the `repository` argument, you also need to set `oauthToken` or `accessToken` for authentication. For GitHub, get a [personal access token](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line) and set `accessToken` as follows: * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.amplify.App("example", { * name: "example", * repository: "https://github.com/example/app", * accessToken: "...", * }); * ``` * * You can omit `accessToken` if you import an existing Amplify App created by the Amplify Console (using OAuth for authentication). * * ### Auto Branch Creation * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.amplify.App("example", { * name: "example", * enableAutoBranchCreation: true, * autoBranchCreationPatterns: [ * "*", * "*&#47;**", * ], * autoBranchCreationConfig: { * enableAutoBuild: true, * }, * }); * ``` * * ### Basic Authorization * * ```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: "example", * enableBasicAuth: true, * basicAuthCredentials: std.base64encode({ * input: "username1:password1", * }).then(invoke => invoke.result), * }); * ``` * * ### Rewrites and Redirects * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.amplify.App("example", { * name: "example", * customRules: [ * { * source: "/api/<*>", * status: "200", * target: "https://api.example.com/api/<*>", * }, * { * source: "</^[^.]+$|\\.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|ttf|map|json)$)([^.]+$)/>", * status: "200", * target: "/index.html", * }, * ], * }); * ``` * * ### Custom Image * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.amplify.App("example", { * name: "example", * environmentVariables: { * _CUSTOM_IMAGE: "node:16", * }, * }); * ``` * * ### Custom Headers * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.amplify.App("example", { * name: "example", * customHeaders: `customHeaders: * - pattern: '**' * headers: * - key: 'Strict-Transport-Security' * value: 'max-age=31536000; includeSubDomains' * - key: 'X-Frame-Options' * value: 'SAMEORIGIN' * - key: 'X-XSS-Protection' * value: '1; mode=block' * - key: 'X-Content-Type-Options' * value: 'nosniff' * - key: 'Content-Security-Policy' * value: "default-src 'self'" * `, * }); * ``` * * ### Job Config * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.amplify.App("example", { * name: "example", * jobConfig: { * buildComputeType: "STANDARD_8GB", * }, * }); * ``` * * ## Import * * Using `pulumi import`, import Amplify App using Amplify App ID (appId). For example: * * ```sh * $ pulumi import aws:amplify/app:App example d2ypk4k47z8u6 * ``` * App ID can be obtained from App ARN (e.g., `arn:aws:amplify:us-east-1:12345678:apps/d2ypk4k47z8u6`). */ class App extends pulumi.CustomResource { /** * Get an existing App 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 App(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of App. 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'] === App.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["accessToken"] = state?.accessToken; resourceInputs["arn"] = state?.arn; resourceInputs["autoBranchCreationConfig"] = state?.autoBranchCreationConfig; resourceInputs["autoBranchCreationPatterns"] = state?.autoBranchCreationPatterns; resourceInputs["basicAuthCredentials"] = state?.basicAuthCredentials; resourceInputs["buildSpec"] = state?.buildSpec; resourceInputs["cacheConfig"] = state?.cacheConfig; resourceInputs["computeRoleArn"] = state?.computeRoleArn; resourceInputs["customHeaders"] = state?.customHeaders; resourceInputs["customRules"] = state?.customRules; resourceInputs["defaultDomain"] = state?.defaultDomain; resourceInputs["description"] = state?.description; resourceInputs["enableAutoBranchCreation"] = state?.enableAutoBranchCreation; resourceInputs["enableBasicAuth"] = state?.enableBasicAuth; resourceInputs["enableBranchAutoBuild"] = state?.enableBranchAutoBuild; resourceInputs["enableBranchAutoDeletion"] = state?.enableBranchAutoDeletion; resourceInputs["environmentVariables"] = state?.environmentVariables; resourceInputs["iamServiceRoleArn"] = state?.iamServiceRoleArn; resourceInputs["jobConfig"] = state?.jobConfig; resourceInputs["name"] = state?.name; resourceInputs["oauthToken"] = state?.oauthToken; resourceInputs["platform"] = state?.platform; resourceInputs["productionBranches"] = state?.productionBranches; resourceInputs["region"] = state?.region; resourceInputs["repository"] = state?.repository; resourceInputs["tags"] = state?.tags; resourceInputs["tagsAll"] = state?.tagsAll; } else { const args = argsOrState; resourceInputs["accessToken"] = args?.accessToken ? pulumi.secret(args.accessToken) : undefined; resourceInputs["autoBranchCreationConfig"] = args?.autoBranchCreationConfig; resourceInputs["autoBranchCreationPatterns"] = args?.autoBranchCreationPatterns; resourceInputs["basicAuthCredentials"] = args?.basicAuthCredentials ? pulumi.secret(args.basicAuthCredentials) : undefined; resourceInputs["buildSpec"] = args?.buildSpec; resourceInputs["cacheConfig"] = args?.cacheConfig; resourceInputs["computeRoleArn"] = args?.computeRoleArn; resourceInputs["customHeaders"] = args?.customHeaders; resourceInputs["customRules"] = args?.customRules; resourceInputs["description"] = args?.description; resourceInputs["enableAutoBranchCreation"] = args?.enableAutoBranchCreation; resourceInputs["enableBasicAuth"] = args?.enableBasicAuth; resourceInputs["enableBranchAutoBuild"] = args?.enableBranchAutoBuild; resourceInputs["enableBranchAutoDeletion"] = args?.enableBranchAutoDeletion; resourceInputs["environmentVariables"] = args?.environmentVariables; resourceInputs["iamServiceRoleArn"] = args?.iamServiceRoleArn; resourceInputs["jobConfig"] = args?.jobConfig; resourceInputs["name"] = args?.name; resourceInputs["oauthToken"] = args?.oauthToken ? pulumi.secret(args.oauthToken) : undefined; resourceInputs["platform"] = args?.platform; resourceInputs["region"] = args?.region; resourceInputs["repository"] = args?.repository; resourceInputs["tags"] = args?.tags; resourceInputs["arn"] = undefined /*out*/; resourceInputs["defaultDomain"] = undefined /*out*/; resourceInputs["productionBranches"] = undefined /*out*/; resourceInputs["tagsAll"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); const secretOpts = { additionalSecretOutputs: ["accessToken", "basicAuthCredentials", "oauthToken"] }; opts = pulumi.mergeOptions(opts, secretOpts); super(App.__pulumiType, name, resourceInputs, opts); } } exports.App = App; /** @internal */ App.__pulumiType = 'aws:amplify/app:App'; //# sourceMappingURL=app.js.map