@pattform/api-kit 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AppComponent.d.ts +6 -0
- package/dist/AppComponent.js +29 -20
- package/package.json +1 -1
package/dist/AppComponent.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as pulumi from "@pulumi/pulumi";
|
|
2
|
+
import * as aws from "@pulumi/aws";
|
|
2
3
|
export declare class AppComponent extends pulumi.ComponentResource {
|
|
3
4
|
readonly requiredDnsRecords: pulumi.Output<DnsRecordInstruction[]>;
|
|
4
5
|
private readonly amplifyApp;
|
|
@@ -15,6 +16,11 @@ export interface AppComponentArgs {
|
|
|
15
16
|
buildSpec?: string;
|
|
16
17
|
roleArn?: pulumi.Input<string>;
|
|
17
18
|
manageDns?: boolean;
|
|
19
|
+
customRules?: aws.types.input.amplify.AppCustomRule[];
|
|
20
|
+
environmentVariables?: {
|
|
21
|
+
[key: string]: pulumi.Input<string>;
|
|
22
|
+
};
|
|
23
|
+
manageValidationRecord?: boolean;
|
|
18
24
|
}
|
|
19
25
|
export interface DnsRecordInstruction {
|
|
20
26
|
name: string;
|
package/dist/AppComponent.js
CHANGED
|
@@ -7,7 +7,7 @@ const cloudflare = require("@pulumi/cloudflare");
|
|
|
7
7
|
const pattformHelper_1 = require("./pattformHelper");
|
|
8
8
|
class AppComponent extends pulumi.ComponentResource {
|
|
9
9
|
constructor(name, args, opts) {
|
|
10
|
-
var _a, _b;
|
|
10
|
+
var _a, _b, _c, _d;
|
|
11
11
|
super("custom:pattform:AppComponent", name, args, opts);
|
|
12
12
|
const awsConfig = new pulumi.Config("aws");
|
|
13
13
|
const awsRegion = awsConfig.require("region");
|
|
@@ -78,7 +78,17 @@ class AppComponent extends pulumi.ComponentResource {
|
|
|
78
78
|
}
|
|
79
79
|
const subDomains = getSubDomains();
|
|
80
80
|
const isWWW = subDomains.find((subDomain) => subDomain.prefix === "www");
|
|
81
|
-
|
|
81
|
+
// Redirect the apex to www (for www sites) plus any caller-supplied
|
|
82
|
+
// rules, e.g. the SPA fallback for single-page apps.
|
|
83
|
+
const customRules = [
|
|
84
|
+
...(isWWW ? [{
|
|
85
|
+
source: "https://" + args.domain,
|
|
86
|
+
target: "https://www." + args.domain,
|
|
87
|
+
status: "302",
|
|
88
|
+
}] : []),
|
|
89
|
+
...((_c = args.customRules) !== null && _c !== void 0 ? _c : []),
|
|
90
|
+
];
|
|
91
|
+
this.amplifyApp = new aws.amplify.App(`${appName}-amplifyApp-${env}`, Object.assign(Object.assign(Object.assign({ name: appName, repository: args.repoUrl, accessToken: githubToken, autoBranchCreationConfig: {
|
|
82
92
|
enableAutoBuild: true,
|
|
83
93
|
enableBasicAuth: false,
|
|
84
94
|
enablePerformanceMode: false,
|
|
@@ -88,15 +98,7 @@ class AppComponent extends pulumi.ComponentResource {
|
|
|
88
98
|
"feature/*",
|
|
89
99
|
"bugfix/*",
|
|
90
100
|
"hotfix/*",
|
|
91
|
-
], enableBranchAutoDeletion: true, enableBranchAutoBuild: true, enableAutoBranchCreation: true },
|
|
92
|
-
customRules: [
|
|
93
|
-
{
|
|
94
|
-
source: "https://" + args.domain,
|
|
95
|
-
target: "https://www." + args.domain,
|
|
96
|
-
status: "302",
|
|
97
|
-
}
|
|
98
|
-
]
|
|
99
|
-
}), { buildSpec: args.buildSpec || `
|
|
101
|
+
], enableBranchAutoDeletion: true, enableBranchAutoBuild: true, enableAutoBranchCreation: true }, (customRules.length > 0 ? { customRules } : {})), (args.environmentVariables ? { environmentVariables: args.environmentVariables } : {})), { buildSpec: args.buildSpec || `
|
|
100
102
|
version: 1.0
|
|
101
103
|
frontend:
|
|
102
104
|
phases:
|
|
@@ -147,15 +149,22 @@ class AppComponent extends pulumi.ComponentResource {
|
|
|
147
149
|
}, {
|
|
148
150
|
provider: cloudFlareProvider,
|
|
149
151
|
});
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
152
|
+
// ACM validates domain ownership with one deterministic CNAME per
|
|
153
|
+
// apex, shared across every cert for that domain. When another
|
|
154
|
+
// stack already manages the apex (e.g. the apex/www site while this
|
|
155
|
+
// is a subdomain app), set manageValidationRecord: false to reuse it
|
|
156
|
+
// instead of colliding on an identical record.
|
|
157
|
+
if ((_d = args.manageValidationRecord) !== null && _d !== void 0 ? _d : true) {
|
|
158
|
+
this.validationRecord = new cloudflare.Record(`${appName}-cloudflareValidateRecord-${env}`, {
|
|
159
|
+
zoneId: cloudflareZone.id,
|
|
160
|
+
name: this.domainAssociation.certificateVerificationDnsRecord.apply(record => record.split(' ')[0]),
|
|
161
|
+
type: "CNAME",
|
|
162
|
+
proxied: false,
|
|
163
|
+
content: this.domainAssociation.certificateVerificationDnsRecord.apply(record => record.split(' ')[2]),
|
|
164
|
+
}, {
|
|
165
|
+
provider: cloudFlareProvider,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
159
168
|
this.subDomainRecords = this.domainAssociation.subDomains.apply(subDomains => {
|
|
160
169
|
return subDomains.map((subDomain) => {
|
|
161
170
|
const subDomainName = subDomain.dnsRecord.split(' ')[0];
|