@webiny/project-aws 6.6.0-alpha.11 → 6.6.0-alpha.13
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/_templates/appTemplates/api/graphql/package.json +2 -2
- package/_templates/appTemplates/api/graphql/src/index.ts +2 -2
- package/_templates/appTemplates/api/graphql/src/web.ts +15 -0
- package/_templates/appTemplates/api/graphql/webiny.config.ts +6 -1
- package/_templates/extensions/OpenSearch/api/graphql/src/index.ts +2 -2
- package/_templates/extensions/OpenSearch/api/graphql/src/web.ts +15 -0
- package/_templates/extensions/Postgres/api/graphql/src/index.ts +17 -0
- package/_templates/extensions/Postgres/api/graphql/src/web.ts +15 -0
- package/api.d.ts +6 -6
- package/api.js +3 -2
- package/api.js.map +1 -1
- package/apps/createApiApp.d.ts +18 -1
- package/apps/createCoreApp.d.ts +1 -1
- package/decorators/GetPulumiServiceWithDownloadInfo.d.ts +1 -3
- package/decorators/GetPulumiServiceWithDownloadInfo.js +15 -11
- package/decorators/GetPulumiServiceWithDownloadInfo.js.map +1 -1
- package/extensions/ApiRoute.d.ts +2 -1
- package/extensions/ApiRoute.js.map +1 -1
- package/extensions/AuroraPostgresCluster.d.ts +12 -0
- package/extensions/AuroraPostgresCluster.js +30 -0
- package/extensions/AuroraPostgresCluster.js.map +1 -0
- package/extensions/Postgres/AddCorePostgres.d.ts +27 -0
- package/extensions/Postgres/AddCorePostgres.js +52 -0
- package/extensions/Postgres/AddCorePostgres.js.map +1 -0
- package/extensions/Postgres/CopyPgModulesAfterApiBuild.d.ts +16 -0
- package/extensions/Postgres/CopyPgModulesAfterApiBuild.js +42 -0
- package/extensions/Postgres/CopyPgModulesAfterApiBuild.js.map +1 -0
- package/extensions/Postgres/ReplaceApiLambdaFnHandlers.d.ts +17 -0
- package/extensions/Postgres/ReplaceApiLambdaFnHandlers.js +33 -0
- package/extensions/Postgres/ReplaceApiLambdaFnHandlers.js.map +1 -0
- package/extensions/Postgres/ValidatePostgresBeforeCoreDeploy.d.ts +23 -0
- package/extensions/Postgres/ValidatePostgresBeforeCoreDeploy.js +41 -0
- package/extensions/Postgres/ValidatePostgresBeforeCoreDeploy.js.map +1 -0
- package/extensions/Postgres/copyPgRuntimeModules.d.ts +27 -0
- package/extensions/Postgres/copyPgRuntimeModules.js +124 -0
- package/extensions/Postgres/copyPgRuntimeModules.js.map +1 -0
- package/extensions/Postgres/rds-ca-bundle.pem +2888 -0
- package/extensions/Postgres/rdsCaBundle.d.ts +13 -0
- package/extensions/Postgres/rdsCaBundle.js +7 -0
- package/extensions/Postgres/rdsCaBundle.js.map +1 -0
- package/extensions/ProjectAws/EnsurePostgresSetupUnchanged.d.ts +20 -0
- package/extensions/ProjectAws/EnsurePostgresSetupUnchanged.js +34 -0
- package/extensions/ProjectAws/EnsurePostgresSetupUnchanged.js.map +1 -0
- package/extensions/ProjectAws/RefuseApiWatchWithPostgres.d.ts +20 -0
- package/extensions/ProjectAws/RefuseApiWatchWithPostgres.js +27 -0
- package/extensions/ProjectAws/RefuseApiWatchWithPostgres.js.map +1 -0
- package/extensions/ProjectAws.js +4 -0
- package/extensions/ProjectAws.js.map +1 -1
- package/extensions/definitions.js +3 -1
- package/extensions/definitions.js.map +1 -1
- package/extensions/index.d.ts +4 -1
- package/extensions/index.js +3 -2
- package/extensions/registerExtensionImplementations.js +3 -1
- package/extensions/registerExtensionImplementations.js.map +1 -1
- package/extensions/toCloudFrontPathPattern.d.ts +5 -0
- package/extensions/toCloudFrontPathPattern.js +8 -0
- package/extensions/toCloudFrontPathPattern.js.map +1 -0
- package/features/Watch/AwsWatch.js +1 -0
- package/features/Watch/AwsWatch.js.map +1 -1
- package/features/Watch/forwarder/createForwarderZip.d.ts +8 -0
- package/features/Watch/forwarder/createForwarderZip.js +19 -0
- package/features/Watch/forwarder/createForwarderZip.js.map +1 -0
- package/features/Watch/forwarder/lambdaHandler.cjs +124 -0
- package/features/Watch/forwarder/lambdaHandler.d.cts +1 -0
- package/features/Watch/forwarder/mqtt.cjs +4 -0
- package/features/Watch/forwarder/mqtt.d.cts +1 -0
- package/features/Watch/forwarder/webHandler.d.mts +1 -0
- package/features/Watch/forwarder/webHandler.mjs +298 -0
- package/features/Watch/replaceLambdaFunctions.d.ts +2 -0
- package/features/Watch/replaceLambdaFunctions.js +44 -3
- package/features/Watch/replaceLambdaFunctions.js.map +1 -1
- package/features/Watch/replaceWebFunction.d.ts +44 -0
- package/features/Watch/replaceWebFunction.js +119 -0
- package/features/Watch/replaceWebFunction.js.map +1 -0
- package/infra.d.ts +13 -0
- package/infra.js +8 -6
- package/infra.js.map +1 -1
- package/package.json +21 -17
- package/project.d.ts +1 -0
- package/pulumi/apps/admin/createAdminPulumiApp.js +1 -2
- package/pulumi/apps/admin/createAdminPulumiApp.js.map +1 -1
- package/pulumi/apps/api/ApiCloudfront.d.ts +5 -0
- package/pulumi/apps/api/ApiCloudfront.js +71 -198
- package/pulumi/apps/api/ApiCloudfront.js.map +1 -1
- package/pulumi/apps/api/ApiFileManager.d.ts +8 -1
- package/pulumi/apps/api/ApiFileManager.js +11 -1
- package/pulumi/apps/api/ApiFileManager.js.map +1 -1
- package/pulumi/apps/api/ApiGraphql.d.ts +1 -1
- package/pulumi/apps/api/ApiGraphql.js +78 -69
- package/pulumi/apps/api/ApiGraphql.js.map +1 -1
- package/pulumi/apps/api/ApiGraphqlWeb.d.ts +45 -0
- package/pulumi/apps/api/ApiGraphqlWeb.js +280 -0
- package/pulumi/apps/api/ApiGraphqlWeb.js.map +1 -0
- package/pulumi/apps/api/ApiOutput.d.ts +1 -0
- package/pulumi/apps/api/ApiOutput.js +2 -1
- package/pulumi/apps/api/ApiOutput.js.map +1 -1
- package/pulumi/apps/api/ApiSchemaSetup.d.ts +86 -0
- package/pulumi/apps/api/ApiSchemaSetup.js +139 -0
- package/pulumi/apps/api/ApiSchemaSetup.js.map +1 -0
- package/pulumi/apps/api/apiDynamoDb.d.ts +6 -0
- package/pulumi/apps/api/apiDynamoDb.js +20 -0
- package/pulumi/apps/api/apiDynamoDb.js.map +1 -0
- package/pulumi/apps/api/apiServiceManifests.d.ts +24 -0
- package/pulumi/apps/api/apiServiceManifests.js +27 -0
- package/pulumi/apps/api/apiServiceManifests.js.map +1 -0
- package/pulumi/apps/api/backgroundTask/types.js.map +1 -1
- package/pulumi/apps/api/cloudfront/addWebRouteBehavior.d.ts +8 -0
- package/pulumi/apps/api/cloudfront/addWebRouteBehavior.js +26 -0
- package/pulumi/apps/api/cloudfront/addWebRouteBehavior.js.map +1 -0
- package/pulumi/apps/api/cloudfront/allowFunctionUrlInvoke.d.ts +17 -0
- package/pulumi/apps/api/cloudfront/allowFunctionUrlInvoke.js +27 -0
- package/pulumi/apps/api/cloudfront/allowFunctionUrlInvoke.js.map +1 -0
- package/pulumi/apps/api/cloudfront/allowWebFunctionInvoke.d.ts +8 -0
- package/pulumi/apps/api/cloudfront/allowWebFunctionInvoke.js +31 -0
- package/pulumi/apps/api/cloudfront/allowWebFunctionInvoke.js.map +1 -0
- package/pulumi/apps/api/cloudfront/constants.d.ts +24 -0
- package/pulumi/apps/api/cloudfront/constants.js +43 -0
- package/pulumi/apps/api/cloudfront/constants.js.map +1 -0
- package/pulumi/apps/api/cloudfront/createFilesRouting.d.ts +10 -0
- package/pulumi/apps/api/cloudfront/createFilesRouting.js +35 -0
- package/pulumi/apps/api/cloudfront/createFilesRouting.js.map +1 -0
- package/pulumi/apps/api/cloudfront/createGatewayRouting.d.ts +10 -0
- package/pulumi/apps/api/cloudfront/createGatewayRouting.js +48 -0
- package/pulumi/apps/api/cloudfront/createGatewayRouting.js.map +1 -0
- package/pulumi/apps/api/cloudfront/createStreamRouting.d.ts +10 -0
- package/pulumi/apps/api/cloudfront/createStreamRouting.js +87 -0
- package/pulumi/apps/api/cloudfront/createStreamRouting.js.map +1 -0
- package/pulumi/apps/api/cloudfront/createWebRouting.d.ts +13 -0
- package/pulumi/apps/api/cloudfront/createWebRouting.js +140 -0
- package/pulumi/apps/api/cloudfront/createWebRouting.js.map +1 -0
- package/pulumi/apps/api/createApiPulumiApp.d.ts +22 -4
- package/pulumi/apps/api/createApiPulumiApp.js +122 -81
- package/pulumi/apps/api/createApiPulumiApp.js.map +1 -1
- package/pulumi/apps/api/index.d.ts +2 -0
- package/pulumi/apps/api/index.js +2 -0
- package/pulumi/apps/api/isRouteNameAllowed.d.ts +7 -0
- package/pulumi/apps/api/isRouteNameAllowed.js +6 -0
- package/pulumi/apps/api/isRouteNameAllowed.js.map +1 -0
- package/pulumi/apps/common/CoreOutput.d.ts +13 -0
- package/pulumi/apps/common/CoreOutput.js +17 -2
- package/pulumi/apps/common/CoreOutput.js.map +1 -1
- package/pulumi/apps/core/CoreCognito.d.ts +14 -0
- package/pulumi/apps/core/CoreCognito.js +34 -1
- package/pulumi/apps/core/CoreCognito.js.map +1 -1
- package/pulumi/apps/core/CoreOpenSearch.js +12 -6
- package/pulumi/apps/core/CoreOpenSearch.js.map +1 -1
- package/pulumi/apps/core/CorePostgres.d.ts +48 -0
- package/pulumi/apps/core/CorePostgres.js +262 -0
- package/pulumi/apps/core/CorePostgres.js.map +1 -0
- package/pulumi/apps/core/cognitoIdentityProviders/configure.js +11 -0
- package/pulumi/apps/core/cognitoIdentityProviders/configure.js.map +1 -1
- package/pulumi/apps/core/coreDynamoDb.d.ts +19 -0
- package/pulumi/apps/core/coreDynamoDb.js +34 -0
- package/pulumi/apps/core/coreDynamoDb.js.map +1 -0
- package/pulumi/apps/core/coreServiceManifests.d.ts +31 -0
- package/pulumi/apps/core/coreServiceManifests.js +31 -0
- package/pulumi/apps/core/coreServiceManifests.js.map +1 -0
- package/pulumi/apps/core/coreVpcEndpoints.d.ts +14 -0
- package/pulumi/apps/core/coreVpcEndpoints.js +55 -0
- package/pulumi/apps/core/coreVpcEndpoints.js.map +1 -0
- package/pulumi/apps/core/createCorePulumiApp.d.ts +1 -1
- package/pulumi/apps/core/createCorePulumiApp.js +18 -78
- package/pulumi/apps/core/createCorePulumiApp.js.map +1 -1
- package/pulumi/apps/core/index.d.ts +1 -0
- package/pulumi/apps/core/index.js +1 -0
- package/pulumi/apps/extensions/getPostgresConfigFromExtension.d.ts +15 -0
- package/pulumi/apps/extensions/getPostgresConfigFromExtension.js +16 -0
- package/pulumi/apps/extensions/getPostgresConfigFromExtension.js.map +1 -0
- package/pulumi/apps/extensions/getVpcConfigFromExtension.d.ts +4 -0
- package/pulumi/apps/extensions/isWebFunctionEnabled.d.ts +5 -0
- package/pulumi/apps/extensions/isWebFunctionEnabled.js +9 -0
- package/pulumi/apps/extensions/isWebFunctionEnabled.js.map +1 -0
- package/pulumi/apps/extensions/projectUsesPostgres.d.ts +2 -0
- package/pulumi/apps/extensions/projectUsesPostgres.js +10 -0
- package/pulumi/apps/extensions/projectUsesPostgres.js.map +1 -0
- package/pulumi/apps/react/adminSettingsItem.d.ts +17 -0
- package/pulumi/apps/react/adminSettingsItem.js +28 -0
- package/pulumi/apps/react/adminSettingsItem.js.map +1 -0
- package/pulumi/apps/react/createReactPulumiApp.js +6 -19
- package/pulumi/apps/react/createReactPulumiApp.js.map +1 -1
- package/pulumi/extensions/index.d.ts +12 -45
- package/pulumi/extensions/index.js +2 -1
- package/pulumi/extensions/index.js.map +1 -1
- package/pulumi/types.d.ts +5 -0
- package/pulumi/utils/lambdaEnvVariables.js +2 -2
- package/pulumi/utils/lambdaEnvVariables.js.map +1 -1
- package/pulumi/utils/tagResources.js +2 -0
- package/pulumi/utils/tagResources.js.map +1 -1
- package/pulumi/utils/withServiceManifest.d.ts +35 -1
- package/pulumi/utils/withServiceManifest.js +53 -9
- package/pulumi/utils/withServiceManifest.js.map +1 -1
- package/services/PulumiGetStackOutputService/mapStackOutput.js +1 -1
- package/services/PulumiGetStackOutputService/mapStackOutput.js.map +1 -1
- package/features/Watch/handler/handler.zip +0 -0
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import { createAppModule } from "@webiny/pulumi";
|
|
2
|
+
import * as __rspack_external__pulumi_aws_9e2bee2d from "@pulumi/aws";
|
|
3
|
+
import * as __rspack_external__pulumi_pulumi_f3e773ed from "@pulumi/pulumi";
|
|
4
|
+
import * as __rspack_external__pulumi_random_073a0f72 from "@pulumi/random";
|
|
5
|
+
const POSTGRES_DATABASE = "webiny";
|
|
6
|
+
const POSTGRES_USER = "webiny";
|
|
7
|
+
const POSTGRES_PORT = 5432;
|
|
8
|
+
const ENGINE = "aurora-postgresql";
|
|
9
|
+
const ENGINE_MAJOR_VERSION = "17";
|
|
10
|
+
const PARAMETER_GROUP_FAMILY = "aurora-postgresql17";
|
|
11
|
+
const getLatestEngineVersion = ()=>__rspack_external__pulumi_pulumi_f3e773ed.output(__rspack_external__pulumi_aws_9e2bee2d.rds.getEngineVersion({
|
|
12
|
+
engine: ENGINE,
|
|
13
|
+
version: ENGINE_MAJOR_VERSION,
|
|
14
|
+
latest: true
|
|
15
|
+
})).versionActual;
|
|
16
|
+
const assumeRolePolicy = (service)=>JSON.stringify({
|
|
17
|
+
Version: "2012-10-17",
|
|
18
|
+
Statement: [
|
|
19
|
+
{
|
|
20
|
+
Effect: "Allow",
|
|
21
|
+
Principal: {
|
|
22
|
+
Service: service
|
|
23
|
+
},
|
|
24
|
+
Action: "sts:AssumeRole"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
});
|
|
28
|
+
const CorePostgres = createAppModule({
|
|
29
|
+
name: "CorePostgres",
|
|
30
|
+
config (app, params) {
|
|
31
|
+
const { network, protect } = params;
|
|
32
|
+
const getEngineVersion = params.getEngineVersion ?? getLatestEngineVersion;
|
|
33
|
+
const password = app.addResource(__rspack_external__pulumi_random_073a0f72.RandomPassword, {
|
|
34
|
+
name: "pg-db-password",
|
|
35
|
+
config: {
|
|
36
|
+
length: 32,
|
|
37
|
+
special: false
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
const secret = app.addResource(__rspack_external__pulumi_aws_9e2bee2d.secretsmanager.Secret, {
|
|
41
|
+
name: "pg-db",
|
|
42
|
+
config: {
|
|
43
|
+
description: "Credentials of the Webiny Postgres database.",
|
|
44
|
+
recoveryWindowInDays: protect ? 7 : 0
|
|
45
|
+
},
|
|
46
|
+
opts: {
|
|
47
|
+
protect
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
app.addResource(__rspack_external__pulumi_aws_9e2bee2d.secretsmanager.SecretVersion, {
|
|
51
|
+
name: "pg-db",
|
|
52
|
+
config: {
|
|
53
|
+
secretId: secret.output.id,
|
|
54
|
+
secretString: __rspack_external__pulumi_pulumi_f3e773ed.all([
|
|
55
|
+
password.output.result
|
|
56
|
+
]).apply(([value])=>JSON.stringify({
|
|
57
|
+
username: POSTGRES_USER,
|
|
58
|
+
password: value
|
|
59
|
+
}))
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
const subnetGroup = app.addResource(__rspack_external__pulumi_aws_9e2bee2d.rds.SubnetGroup, {
|
|
63
|
+
name: "pg-db",
|
|
64
|
+
config: {
|
|
65
|
+
description: "Subnets of the Webiny Postgres database.",
|
|
66
|
+
subnetIds: network.subnetIds
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
const parameterGroup = app.addResource(__rspack_external__pulumi_aws_9e2bee2d.rds.ClusterParameterGroup, {
|
|
70
|
+
name: "pg-db",
|
|
71
|
+
config: {
|
|
72
|
+
family: PARAMETER_GROUP_FAMILY,
|
|
73
|
+
description: "Webiny Postgres database: TCP keepalives.",
|
|
74
|
+
parameters: [
|
|
75
|
+
{
|
|
76
|
+
name: "tcp_keepalives_idle",
|
|
77
|
+
value: "60"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: "tcp_keepalives_interval",
|
|
81
|
+
value: "10"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: "tcp_keepalives_count",
|
|
85
|
+
value: "6"
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
const finalSnapshotSuffix = protect ? app.addResource(__rspack_external__pulumi_random_073a0f72.RandomId, {
|
|
91
|
+
name: "pg-db-final-snapshot",
|
|
92
|
+
config: {
|
|
93
|
+
byteLength: 4
|
|
94
|
+
}
|
|
95
|
+
}) : null;
|
|
96
|
+
const cluster = app.addResource(__rspack_external__pulumi_aws_9e2bee2d.rds.Cluster, {
|
|
97
|
+
name: "pg-db",
|
|
98
|
+
config: {
|
|
99
|
+
engine: ENGINE,
|
|
100
|
+
engineMode: "provisioned",
|
|
101
|
+
engineVersion: getEngineVersion(),
|
|
102
|
+
databaseName: POSTGRES_DATABASE,
|
|
103
|
+
masterUsername: POSTGRES_USER,
|
|
104
|
+
masterPassword: password.output.result,
|
|
105
|
+
port: POSTGRES_PORT,
|
|
106
|
+
storageType: "aurora",
|
|
107
|
+
storageEncrypted: true,
|
|
108
|
+
dbSubnetGroupName: subnetGroup.output.name,
|
|
109
|
+
dbClusterParameterGroupName: parameterGroup.output.name,
|
|
110
|
+
vpcSecurityGroupIds: network.securityGroupIds,
|
|
111
|
+
serverlessv2ScalingConfiguration: {
|
|
112
|
+
minCapacity: params.minCapacity,
|
|
113
|
+
maxCapacity: params.maxCapacity
|
|
114
|
+
},
|
|
115
|
+
enabledCloudwatchLogsExports: [
|
|
116
|
+
"postgresql"
|
|
117
|
+
],
|
|
118
|
+
copyTagsToSnapshot: true,
|
|
119
|
+
deletionProtection: protect,
|
|
120
|
+
backupRetentionPeriod: protect ? 35 : 1,
|
|
121
|
+
deleteAutomatedBackups: protect ? false : void 0,
|
|
122
|
+
skipFinalSnapshot: !protect,
|
|
123
|
+
finalSnapshotIdentifier: finalSnapshotSuffix ? __rspack_external__pulumi_pulumi_f3e773ed.interpolate`webiny-pg-final-${finalSnapshotSuffix.output.hex}` : void 0,
|
|
124
|
+
applyImmediately: true
|
|
125
|
+
},
|
|
126
|
+
opts: {
|
|
127
|
+
protect,
|
|
128
|
+
ignoreChanges: [
|
|
129
|
+
"engineVersion"
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
const instances = [];
|
|
134
|
+
for(let index = 0; index <= params.readers; index++){
|
|
135
|
+
const isWriter = 0 === index;
|
|
136
|
+
instances.push(app.addResource(__rspack_external__pulumi_aws_9e2bee2d.rds.ClusterInstance, {
|
|
137
|
+
name: isWriter ? "pg-db-writer" : `pg-db-reader-${index}`,
|
|
138
|
+
config: {
|
|
139
|
+
clusterIdentifier: cluster.output.id,
|
|
140
|
+
instanceClass: "db.serverless",
|
|
141
|
+
engine: ENGINE,
|
|
142
|
+
engineVersion: cluster.output.engineVersion,
|
|
143
|
+
publiclyAccessible: false,
|
|
144
|
+
performanceInsightsEnabled: true,
|
|
145
|
+
promotionTier: isWriter ? 0 : 1,
|
|
146
|
+
applyImmediately: true
|
|
147
|
+
},
|
|
148
|
+
opts: {
|
|
149
|
+
ignoreChanges: [
|
|
150
|
+
"engineVersion"
|
|
151
|
+
]
|
|
152
|
+
}
|
|
153
|
+
}));
|
|
154
|
+
}
|
|
155
|
+
let proxy = null;
|
|
156
|
+
if (params.rdsProxy) proxy = addProxy(app, {
|
|
157
|
+
secret,
|
|
158
|
+
cluster,
|
|
159
|
+
instances,
|
|
160
|
+
network
|
|
161
|
+
});
|
|
162
|
+
return {
|
|
163
|
+
cluster,
|
|
164
|
+
instances,
|
|
165
|
+
secret,
|
|
166
|
+
subnetGroup,
|
|
167
|
+
parameterGroup,
|
|
168
|
+
proxy: proxy?.proxy ?? null,
|
|
169
|
+
outputs: {
|
|
170
|
+
pgWriterHost: cluster.output.endpoint,
|
|
171
|
+
pgReaderHost: cluster.output.readerEndpoint,
|
|
172
|
+
...proxy ? {
|
|
173
|
+
pgProxyHost: proxy.proxy.output.endpoint
|
|
174
|
+
} : {},
|
|
175
|
+
pgPort: POSTGRES_PORT,
|
|
176
|
+
pgDatabase: POSTGRES_DATABASE,
|
|
177
|
+
pgUser: POSTGRES_USER,
|
|
178
|
+
pgSecretArn: secret.output.arn
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
function addProxy(app, params) {
|
|
184
|
+
const { secret, cluster, instances, network } = params;
|
|
185
|
+
const role = app.addResource(__rspack_external__pulumi_aws_9e2bee2d.iam.Role, {
|
|
186
|
+
name: "pg-proxy",
|
|
187
|
+
config: {
|
|
188
|
+
assumeRolePolicy: assumeRolePolicy("rds.amazonaws.com")
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
app.addResource(__rspack_external__pulumi_aws_9e2bee2d.iam.RolePolicy, {
|
|
192
|
+
name: "pg-proxy",
|
|
193
|
+
config: {
|
|
194
|
+
role: role.output.id,
|
|
195
|
+
policy: __rspack_external__pulumi_pulumi_f3e773ed.all([
|
|
196
|
+
secret.output.arn
|
|
197
|
+
]).apply(([arn])=>JSON.stringify({
|
|
198
|
+
Version: "2012-10-17",
|
|
199
|
+
Statement: [
|
|
200
|
+
{
|
|
201
|
+
Effect: "Allow",
|
|
202
|
+
Action: [
|
|
203
|
+
"secretsmanager:GetSecretValue"
|
|
204
|
+
],
|
|
205
|
+
Resource: [
|
|
206
|
+
arn
|
|
207
|
+
]
|
|
208
|
+
}
|
|
209
|
+
]
|
|
210
|
+
}))
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
const proxy = app.addResource(__rspack_external__pulumi_aws_9e2bee2d.rds.Proxy, {
|
|
214
|
+
name: "pg-proxy",
|
|
215
|
+
config: {
|
|
216
|
+
engineFamily: "POSTGRESQL",
|
|
217
|
+
auths: [
|
|
218
|
+
{
|
|
219
|
+
authScheme: "SECRETS",
|
|
220
|
+
iamAuth: "DISABLED",
|
|
221
|
+
secretArn: secret.output.arn
|
|
222
|
+
}
|
|
223
|
+
],
|
|
224
|
+
roleArn: role.output.arn,
|
|
225
|
+
vpcSubnetIds: network.subnetIds,
|
|
226
|
+
vpcSecurityGroupIds: network.securityGroupIds,
|
|
227
|
+
requireTls: true,
|
|
228
|
+
idleClientTimeout: 900,
|
|
229
|
+
debugLogging: false
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
const targetGroup = app.addResource(__rspack_external__pulumi_aws_9e2bee2d.rds.ProxyDefaultTargetGroup, {
|
|
233
|
+
name: "pg-proxy",
|
|
234
|
+
config: {
|
|
235
|
+
dbProxyName: proxy.output.name,
|
|
236
|
+
connectionPoolConfig: {
|
|
237
|
+
maxConnectionsPercent: 70,
|
|
238
|
+
maxIdleConnectionsPercent: 50,
|
|
239
|
+
connectionBorrowTimeout: 10
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
app.addResource(__rspack_external__pulumi_aws_9e2bee2d.rds.ProxyTarget, {
|
|
244
|
+
name: "pg-proxy",
|
|
245
|
+
config: {
|
|
246
|
+
dbProxyName: proxy.output.name,
|
|
247
|
+
targetGroupName: targetGroup.output.name,
|
|
248
|
+
dbClusterIdentifier: cluster.output.id
|
|
249
|
+
},
|
|
250
|
+
opts: {
|
|
251
|
+
dependsOn: instances.map((instance)=>instance.output)
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
return {
|
|
255
|
+
role,
|
|
256
|
+
proxy,
|
|
257
|
+
targetGroup
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
export { CorePostgres, POSTGRES_DATABASE, POSTGRES_PORT, POSTGRES_USER };
|
|
261
|
+
|
|
262
|
+
//# sourceMappingURL=CorePostgres.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pulumi/apps/core/CorePostgres.js","sources":["../../../../src/pulumi/apps/core/CorePostgres.ts"],"sourcesContent":["import * as aws from \"@pulumi/aws\";\nimport * as pulumi from \"@pulumi/pulumi\";\nimport * as random from \"@pulumi/random\";\nimport {\n createAppModule,\n type PulumiApp,\n type PulumiAppModule,\n type PulumiAppResource\n} from \"@webiny/pulumi\";\n\nexport type CorePostgres = PulumiAppModule<typeof CorePostgres>;\n\nexport const POSTGRES_DATABASE = \"webiny\";\nexport const POSTGRES_USER = \"webiny\";\nexport const POSTGRES_PORT = 5432;\n\n/* Aurora PostgreSQL's major version, and its cluster parameter group family. */\nconst ENGINE = \"aurora-postgresql\";\nconst ENGINE_MAJOR_VERSION = \"17\";\nconst PARAMETER_GROUP_FAMILY = \"aurora-postgresql17\";\n\nexport interface PostgresNetwork {\n subnetIds: pulumi.Input<pulumi.Input<string>[]>;\n securityGroupIds: pulumi.Input<pulumi.Input<string>[]>;\n}\n\nexport interface CorePostgresParams {\n minCapacity: number;\n maxCapacity: number;\n readers: number;\n rdsProxy: boolean;\n network: PostgresNetwork;\n /*\n * On in production: deletion protection, 35 days of backups that outlive the cluster, and a\n * final snapshot.\n */\n protect: boolean;\n /*\n * The engine version a new cluster gets: the latest 17.x. Replaced in tests, where there is no\n * AWS to ask.\n */\n getEngineVersion?: () => pulumi.Input<string>;\n}\n\nconst getLatestEngineVersion = () => {\n return pulumi.output(\n aws.rds.getEngineVersion({ engine: ENGINE, version: ENGINE_MAJOR_VERSION, latest: true })\n ).versionActual;\n};\n\nconst assumeRolePolicy = (service: string) =>\n JSON.stringify({\n Version: \"2012-10-17\",\n Statement: [{ Effect: \"Allow\", Principal: { Service: service }, Action: \"sts:AssumeRole\" }]\n });\n\n/**\n * The Postgres database of a project with `<Infra.AuroraPostgres />`: an Aurora PostgreSQL 17\n * Serverless v2 cluster with a writer and `readers` reader instances, and its credentials in a\n * Secrets Manager secret (`{ username, password }`). With `rdsProxy`, an RDS Proxy in front of it,\n * which reads the same secret.\n *\n * The cluster, its instances and the proxy go into `network`: the private subnets of the VPC the\n * core app creates and its default security group, which the API functions use too, or the\n * `postgresVpcConfig` of an existing VPC.\n *\n * No password leaves this module: the API reads it from the secret.\n */\nexport const CorePostgres = createAppModule({\n name: \"CorePostgres\",\n config(app: PulumiApp, params: CorePostgresParams) {\n const { network, protect } = params;\n const getEngineVersion = params.getEngineVersion ?? getLatestEngineVersion;\n\n const password = app.addResource(random.RandomPassword, {\n name: \"pg-db-password\",\n config: { length: 32, special: false }\n });\n\n const secret = app.addResource(aws.secretsmanager.Secret, {\n name: \"pg-db\",\n config: {\n description: \"Credentials of the Webiny Postgres database.\",\n // Outside production, a destroyed project can be deployed again at once.\n recoveryWindowInDays: protect ? 7 : 0\n },\n opts: { protect }\n });\n\n app.addResource(aws.secretsmanager.SecretVersion, {\n name: \"pg-db\",\n config: {\n secretId: secret.output.id,\n secretString: pulumi\n .all([password.output.result])\n .apply(([value]) =>\n JSON.stringify({ username: POSTGRES_USER, password: value })\n )\n }\n });\n\n const subnetGroup = app.addResource(aws.rds.SubnetGroup, {\n name: \"pg-db\",\n config: {\n description: \"Subnets of the Webiny Postgres database.\",\n subnetIds: network.subnetIds\n }\n });\n\n /*\n * The server notices a client that went away without closing its connection (a Lambda\n * environment that was recycled) within about two minutes, and frees the connection.\n */\n const parameterGroup = app.addResource(aws.rds.ClusterParameterGroup, {\n name: \"pg-db\",\n config: {\n family: PARAMETER_GROUP_FAMILY,\n description: \"Webiny Postgres database: TCP keepalives.\",\n parameters: [\n { name: \"tcp_keepalives_idle\", value: \"60\" },\n { name: \"tcp_keepalives_interval\", value: \"10\" },\n { name: \"tcp_keepalives_count\", value: \"6\" }\n ]\n }\n });\n\n // A final snapshot needs a name that no earlier snapshot of the account has.\n const finalSnapshotSuffix = protect\n ? app.addResource(random.RandomId, {\n name: \"pg-db-final-snapshot\",\n config: { byteLength: 4 }\n })\n : null;\n\n const cluster = app.addResource(aws.rds.Cluster, {\n name: \"pg-db\",\n config: {\n engine: ENGINE,\n engineMode: \"provisioned\",\n engineVersion: getEngineVersion(),\n databaseName: POSTGRES_DATABASE,\n masterUsername: POSTGRES_USER,\n masterPassword: password.output.result,\n port: POSTGRES_PORT,\n storageType: \"aurora\",\n storageEncrypted: true,\n dbSubnetGroupName: subnetGroup.output.name,\n dbClusterParameterGroupName: parameterGroup.output.name,\n vpcSecurityGroupIds: network.securityGroupIds,\n serverlessv2ScalingConfiguration: {\n minCapacity: params.minCapacity,\n maxCapacity: params.maxCapacity\n },\n enabledCloudwatchLogsExports: [\"postgresql\"],\n copyTagsToSnapshot: true,\n deletionProtection: protect,\n // Point-in-time restore is always on in Aurora; this is its window. Production\n // keeps the maximum, 35 days, the same as DynamoDB's point-in-time recovery.\n // Backup storage up to the cluster volume's size is free. Elsewhere, 1 day.\n backupRetentionPeriod: protect ? 35 : 1,\n // Production keeps its automated backups when the cluster is deleted, so it can\n // still be restored to a point in time until the window runs out. The first day is\n // free, later days are billed, and a region holds at most 40 retained automated\n // backups. Elsewhere the default (true) applies: a destroyed environment leaves\n // nothing behind.\n deleteAutomatedBackups: protect ? false : undefined,\n skipFinalSnapshot: !protect,\n finalSnapshotIdentifier: finalSnapshotSuffix\n ? pulumi.interpolate`webiny-pg-final-${finalSnapshotSuffix.output.hex}`\n : undefined,\n // Capacity changes apply now, not in the next maintenance window.\n applyImmediately: true\n },\n opts: {\n protect,\n // The version is picked when the cluster is created; AWS applies minor upgrades.\n // A newer 17.x must not make a later deploy upgrade the cluster.\n ignoreChanges: [\"engineVersion\"]\n }\n });\n\n const instances = [];\n for (let index = 0; index <= params.readers; index++) {\n const isWriter = index === 0;\n instances.push(\n app.addResource(aws.rds.ClusterInstance, {\n name: isWriter ? \"pg-db-writer\" : `pg-db-reader-${index}`,\n config: {\n clusterIdentifier: cluster.output.id,\n instanceClass: \"db.serverless\",\n engine: ENGINE,\n engineVersion: cluster.output.engineVersion,\n publiclyAccessible: false,\n performanceInsightsEnabled: true,\n // Readers in tier 0–1 scale with the writer, so a failover lands on a warm one.\n promotionTier: isWriter ? 0 : 1,\n applyImmediately: true\n },\n opts: { ignoreChanges: [\"engineVersion\"] }\n })\n );\n }\n\n let proxy: ReturnType<typeof addProxy> | null = null;\n if (params.rdsProxy) {\n proxy = addProxy(app, { secret, cluster, instances, network });\n }\n\n return {\n cluster,\n instances,\n secret,\n subnetGroup,\n parameterGroup,\n proxy: proxy?.proxy ?? null,\n outputs: {\n pgWriterHost: cluster.output.endpoint,\n pgReaderHost: cluster.output.readerEndpoint,\n ...(proxy ? { pgProxyHost: proxy.proxy.output.endpoint } : {}),\n pgPort: POSTGRES_PORT,\n pgDatabase: POSTGRES_DATABASE,\n pgUser: POSTGRES_USER,\n pgSecretArn: secret.output.arn\n }\n };\n }\n});\n\ninterface AddProxyParams {\n secret: PulumiAppResource<typeof aws.secretsmanager.Secret>;\n cluster: PulumiAppResource<typeof aws.rds.Cluster>;\n instances: PulumiAppResource<typeof aws.rds.ClusterInstance>[];\n network: PostgresNetwork;\n}\n\nfunction addProxy(app: PulumiApp, params: AddProxyParams) {\n const { secret, cluster, instances, network } = params;\n\n const role = app.addResource(aws.iam.Role, {\n name: \"pg-proxy\",\n config: { assumeRolePolicy: assumeRolePolicy(\"rds.amazonaws.com\") }\n });\n\n app.addResource(aws.iam.RolePolicy, {\n name: \"pg-proxy\",\n config: {\n role: role.output.id,\n policy: pulumi.all([secret.output.arn]).apply(([arn]) =>\n JSON.stringify({\n Version: \"2012-10-17\",\n Statement: [\n {\n Effect: \"Allow\",\n Action: [\"secretsmanager:GetSecretValue\"],\n Resource: [arn]\n }\n ]\n })\n )\n }\n });\n\n const proxy = app.addResource(aws.rds.Proxy, {\n name: \"pg-proxy\",\n config: {\n engineFamily: \"POSTGRESQL\",\n auths: [{ authScheme: \"SECRETS\", iamAuth: \"DISABLED\", secretArn: secret.output.arn }],\n roleArn: role.output.arn,\n vpcSubnetIds: network.subnetIds,\n vpcSecurityGroupIds: network.securityGroupIds,\n requireTls: true,\n idleClientTimeout: 900,\n debugLogging: false\n }\n });\n\n const targetGroup = app.addResource(aws.rds.ProxyDefaultTargetGroup, {\n name: \"pg-proxy\",\n config: {\n dbProxyName: proxy.output.name,\n connectionPoolConfig: {\n maxConnectionsPercent: 70,\n maxIdleConnectionsPercent: 50,\n connectionBorrowTimeout: 10\n }\n }\n });\n\n app.addResource(aws.rds.ProxyTarget, {\n name: \"pg-proxy\",\n config: {\n dbProxyName: proxy.output.name,\n targetGroupName: targetGroup.output.name,\n dbClusterIdentifier: cluster.output.id\n },\n // The proxy can only register a cluster whose instances are available.\n opts: { dependsOn: instances.map(instance => instance.output) }\n });\n\n return { role, proxy, targetGroup };\n}\n"],"names":["POSTGRES_DATABASE","POSTGRES_USER","POSTGRES_PORT","ENGINE","ENGINE_MAJOR_VERSION","PARAMETER_GROUP_FAMILY","getLatestEngineVersion","pulumi","aws","assumeRolePolicy","service","JSON","CorePostgres","createAppModule","app","params","network","protect","getEngineVersion","password","random","secret","value","subnetGroup","parameterGroup","finalSnapshotSuffix","cluster","undefined","instances","index","isWriter","proxy","addProxy","role","arn","targetGroup","instance"],"mappings":";;;;AAYO,MAAMA,oBAAoB;AAC1B,MAAMC,gBAAgB;AACtB,MAAMC,gBAAgB;AAG7B,MAAMC,SAAS;AACf,MAAMC,uBAAuB;AAC7B,MAAMC,yBAAyB;AAyB/B,MAAMC,yBAAyB,IACpBC,0CAAAA,MAAa,CAChBC,uCAAAA,GAAAA,CAAAA,gBAAwB,CAAC;QAAE,QAAQL;QAAQ,SAASC;QAAsB,QAAQ;IAAK,IACzF,aAAa;AAGnB,MAAMK,mBAAmB,CAACC,UACtBC,KAAK,SAAS,CAAC;QACX,SAAS;QACT,WAAW;YAAC;gBAAE,QAAQ;gBAAS,WAAW;oBAAE,SAASD;gBAAQ;gBAAG,QAAQ;YAAiB;SAAE;IAC/F;AAcG,MAAME,eAAeC,gBAAgB;IACxC,MAAM;IACN,QAAOC,GAAc,EAAEC,MAA0B;QAC7C,MAAM,EAAEC,OAAO,EAAEC,OAAO,EAAE,GAAGF;QAC7B,MAAMG,mBAAmBH,OAAO,gBAAgB,IAAIT;QAEpD,MAAMa,WAAWL,IAAI,WAAW,CAACM,0CAAAA,cAAqB,EAAE;YACpD,MAAM;YACN,QAAQ;gBAAE,QAAQ;gBAAI,SAAS;YAAM;QACzC;QAEA,MAAMC,SAASP,IAAI,WAAW,CAACN,uCAAAA,cAAAA,CAAAA,MAAyB,EAAE;YACtD,MAAM;YACN,QAAQ;gBACJ,aAAa;gBAEb,sBAAsBS,UAAU,IAAI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Ac;QAClB;IACJ;IAEA,MAAMmB,cAAcrB,IAAI,WAAW,CAACN,uCAAAA,GAAAA,CAAAA,uBAA+B,EAAE;QACjE,MAAM;QACN,QAAQ;YACJ,aAAauB,MAAM,MAAM,CAAC,IAAI;YAC9B,sBAAsB;gBAClB,uBAAuB;gBACvB,2BAA2B;gBAC3B,yBAAyB;YAC7B;QACJ;IACJ;IAEAjB,IAAI,WAAW,CAACN,uCAAAA,GAAAA,CAAAA,WAAmB,EAAE;QACjC,MAAM;QACN,QAAQ;YACJ,aAAauB,MAAM,MAAM,CAAC,IAAI;YAC9B,iBAAiBI,YAAY,MAAM,CAAC,IAAI;YACxC,qBAAqBT,QAAQ,MAAM,CAAC,EAAE;QAC1C;QAEA,MAAM;YAAE,WAAWE,UAAU,GAAG,CAACQ,CAAAA,WAAYA,SAAS,MAAM;QAAE;IAClE;IAEA,OAAO;QAAEH;QAAMF;QAAOI;IAAY;AACtC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getIdpConfig } from "./getIdpConfig.js";
|
|
2
|
+
import { getUserWritableAttributes } from "../CoreCognito.js";
|
|
2
3
|
import { getEnvVariableAwsRegion } from "../../../env/awsRegion.js";
|
|
3
4
|
import * as __rspack_external__pulumi_aws_9e2bee2d from "@pulumi/aws";
|
|
4
5
|
import * as __rspack_external__pulumi_pulumi_f3e773ed from "@pulumi/pulumi";
|
|
@@ -41,6 +42,16 @@ const configureAdminCognitoFederation = (app, config)=>{
|
|
|
41
42
|
return config.providerType;
|
|
42
43
|
})
|
|
43
44
|
]);
|
|
45
|
+
const mappedAttributes = idpConfigs.flatMap((config)=>{
|
|
46
|
+
const mapping = config.attributeMapping || {};
|
|
47
|
+
return Object.keys(mapping).filter((name)=>"username" !== name);
|
|
48
|
+
});
|
|
49
|
+
appClient.config.writeAttributes(getUserWritableAttributes(userPool.output.schemas).apply((attributes)=>[
|
|
50
|
+
...new Set([
|
|
51
|
+
...attributes,
|
|
52
|
+
...mappedAttributes
|
|
53
|
+
])
|
|
54
|
+
]));
|
|
44
55
|
appClient.config.allowedOauthScopes([
|
|
45
56
|
"profile",
|
|
46
57
|
"email",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pulumi/apps/core/cognitoIdentityProviders/configure.js","sources":["../../../../../src/pulumi/apps/core/cognitoIdentityProviders/configure.ts"],"sourcesContent":["import * as aws from \"@pulumi/aws\";\nimport { type UserPoolDomainArgs } from \"@pulumi/aws/cognito/userPoolDomain.js\";\nimport { type IdentityProviderArgs } from \"@pulumi/aws/cognito/index.js\";\nimport * as pulumi from \"@pulumi/pulumi\";\nimport {\n type PulumiApp,\n type PulumiAppResource,\n type PulumiAppResourceConstructor\n} from \"@webiny/pulumi\";\nimport { getIdpConfig } from \"./getIdpConfig.js\";\nimport { getEnvVariableAwsRegion } from \"~/pulumi/env/awsRegion.js\";\n\nexport type IdentityAttributeMapping = {\n \"custom:id\": string;\n username: string;\n email: string;\n family_name: string;\n given_name: string;\n [key: string]: string;\n};\n\nexport interface CognitoIdentityProvidersConfig {\n domain:\n | string\n | {\n name: UserPoolDomainArgs[\"domain\"];\n certificateArn?: UserPoolDomainArgs[\"certificateArn\"];\n };\n identityProviders: CognitoIdentityProviderConfig[];\n callbackUrls: string[];\n logoutUrls?: string[];\n}\n\nexport interface CognitoIdentityProviderConfig {\n name?: string;\n type: \"google\" | \"facebook\" | \"amazon\" | \"apple\" | \"oidc\";\n providerDetails: IdentityProviderArgs[\"providerDetails\"];\n idpIdentifiers?: IdentityProviderArgs[\"idpIdentifiers\"];\n attributeMapping?: IdentityAttributeMapping;\n}\n\nconst isString = (value?: any): value is string => {\n return typeof value === \"string\";\n};\n\nexport const configureAdminCognitoFederation = (\n app: PulumiApp,\n config: CognitoIdentityProvidersConfig\n) => {\n const region = getEnvVariableAwsRegion();\n\n const userPool = app.resources.userPool as PulumiAppResource<\n PulumiAppResourceConstructor<aws.cognito.UserPool>\n >;\n\n const appClient = app.resources.userPoolClient as PulumiAppResource<\n PulumiAppResourceConstructor<aws.cognito.UserPoolClient>\n >;\n\n /**\n * We need to create a user pool domain, which is used to interact with the federated identity providers.\n */\n const userPoolDomain = app.addResource(aws.cognito.UserPoolDomain, {\n name: \"cognitoUserPoolDomain\",\n config: {\n domain: isString(config.domain) ? config.domain : config.domain.name,\n certificateArn: isString(config.domain) ? undefined : config.domain.certificateArn,\n userPoolId: userPool.output.id\n }\n });\n\n app.addOutput(\n \"cognitoUserPoolDomain\",\n pulumi.interpolate`${userPoolDomain.output.domain}.auth.${region}.amazoncognito.com`\n );\n\n const idpConfigs: aws.cognito.IdentityProviderArgs[] = [];\n const idpOutputs: pulumi.Output<aws.cognito.IdentityProvider>[] = [];\n\n for (const idp of config.identityProviders) {\n const config = getIdpConfig(idp.type, userPool.output.id, idp);\n\n // The idea to lowercase the provider name emerged while working on backwards compatibility issue.\n // Basically, in cases where a user used the OIDC provider and did not specify a name, instead of\n // using `OIDC` as the name, we wanted to ensure `oidc` is used. But, what I soon realized is that\n // by simply lowercasing the name, we can avoid the need to check for the provider type and name.\n // And although this will now happen for all providers, it's not a problem since Pulumi requires\n // names to be all lowercase anyway.\n const name = config.providerName.toString().toLowerCase();\n\n const idpResource = app.addResource(aws.cognito.IdentityProvider, { name, config });\n idpOutputs.push(idpResource.output);\n\n idpConfigs.push(config);\n }\n\n appClient.opts.dependsOn = [\n ...(appClient.opts.dependsOn\n ? Array.isArray(appClient.opts.dependsOn)\n ? appClient.opts.dependsOn\n : [appClient.opts.dependsOn]\n : []),\n ...idpOutputs\n ] as pulumi.Input<pulumi.Resource>[];\n\n appClient.config.supportedIdentityProviders([\n \"COGNITO\",\n ...idpConfigs.map(config => {\n // For built-in identity providers, we use the type as the name. Only for OIDC,\n // we allow the user to provide a custom name, and we only use the type as a fallback.\n if (config.providerType === \"OIDC\") {\n return config.providerName;\n }\n return config.providerType;\n })\n ]);\n\n appClient.config.allowedOauthScopes([\"profile\", \"email\", \"openid\"]);\n appClient.config.allowedOauthFlows([\"implicit\", \"code\"]);\n appClient.config.allowedOauthFlowsUserPoolClient(true);\n appClient.config.callbackUrls(config.callbackUrls);\n appClient.config.logoutUrls(config.logoutUrls ?? config.callbackUrls);\n};\n"],"names":["isString","value","configureAdminCognitoFederation","app","config","region","getEnvVariableAwsRegion","userPool","appClient","userPoolDomain","aws","undefined","pulumi","idpConfigs","idpOutputs","idp","getIdpConfig","name","idpResource","Array"],"mappings":"
|
|
1
|
+
{"version":3,"file":"pulumi/apps/core/cognitoIdentityProviders/configure.js","sources":["../../../../../src/pulumi/apps/core/cognitoIdentityProviders/configure.ts"],"sourcesContent":["import * as aws from \"@pulumi/aws\";\nimport { type UserPoolDomainArgs } from \"@pulumi/aws/cognito/userPoolDomain.js\";\nimport { type IdentityProviderArgs } from \"@pulumi/aws/cognito/index.js\";\nimport * as pulumi from \"@pulumi/pulumi\";\nimport {\n type PulumiApp,\n type PulumiAppResource,\n type PulumiAppResourceConstructor\n} from \"@webiny/pulumi\";\nimport { getIdpConfig } from \"./getIdpConfig.js\";\nimport { getUserWritableAttributes } from \"../CoreCognito.js\";\nimport { getEnvVariableAwsRegion } from \"~/pulumi/env/awsRegion.js\";\n\nexport type IdentityAttributeMapping = {\n \"custom:id\": string;\n username: string;\n email: string;\n family_name: string;\n given_name: string;\n [key: string]: string;\n};\n\nexport interface CognitoIdentityProvidersConfig {\n domain:\n | string\n | {\n name: UserPoolDomainArgs[\"domain\"];\n certificateArn?: UserPoolDomainArgs[\"certificateArn\"];\n };\n identityProviders: CognitoIdentityProviderConfig[];\n callbackUrls: string[];\n logoutUrls?: string[];\n}\n\nexport interface CognitoIdentityProviderConfig {\n name?: string;\n type: \"google\" | \"facebook\" | \"amazon\" | \"apple\" | \"oidc\";\n providerDetails: IdentityProviderArgs[\"providerDetails\"];\n idpIdentifiers?: IdentityProviderArgs[\"idpIdentifiers\"];\n attributeMapping?: IdentityAttributeMapping;\n}\n\nconst isString = (value?: any): value is string => {\n return typeof value === \"string\";\n};\n\nexport const configureAdminCognitoFederation = (\n app: PulumiApp,\n config: CognitoIdentityProvidersConfig\n) => {\n const region = getEnvVariableAwsRegion();\n\n const userPool = app.resources.userPool as PulumiAppResource<\n PulumiAppResourceConstructor<aws.cognito.UserPool>\n >;\n\n const appClient = app.resources.userPoolClient as PulumiAppResource<\n PulumiAppResourceConstructor<aws.cognito.UserPoolClient>\n >;\n\n /**\n * We need to create a user pool domain, which is used to interact with the federated identity providers.\n */\n const userPoolDomain = app.addResource(aws.cognito.UserPoolDomain, {\n name: \"cognitoUserPoolDomain\",\n config: {\n domain: isString(config.domain) ? config.domain : config.domain.name,\n certificateArn: isString(config.domain) ? undefined : config.domain.certificateArn,\n userPoolId: userPool.output.id\n }\n });\n\n app.addOutput(\n \"cognitoUserPoolDomain\",\n pulumi.interpolate`${userPoolDomain.output.domain}.auth.${region}.amazoncognito.com`\n );\n\n const idpConfigs: aws.cognito.IdentityProviderArgs[] = [];\n const idpOutputs: pulumi.Output<aws.cognito.IdentityProvider>[] = [];\n\n for (const idp of config.identityProviders) {\n const config = getIdpConfig(idp.type, userPool.output.id, idp);\n\n // The idea to lowercase the provider name emerged while working on backwards compatibility issue.\n // Basically, in cases where a user used the OIDC provider and did not specify a name, instead of\n // using `OIDC` as the name, we wanted to ensure `oidc` is used. But, what I soon realized is that\n // by simply lowercasing the name, we can avoid the need to check for the provider type and name.\n // And although this will now happen for all providers, it's not a problem since Pulumi requires\n // names to be all lowercase anyway.\n const name = config.providerName.toString().toLowerCase();\n\n const idpResource = app.addResource(aws.cognito.IdentityProvider, { name, config });\n idpOutputs.push(idpResource.output);\n\n idpConfigs.push(config);\n }\n\n appClient.opts.dependsOn = [\n ...(appClient.opts.dependsOn\n ? Array.isArray(appClient.opts.dependsOn)\n ? appClient.opts.dependsOn\n : [appClient.opts.dependsOn]\n : []),\n ...idpOutputs\n ] as pulumi.Input<pulumi.Resource>[];\n\n appClient.config.supportedIdentityProviders([\n \"COGNITO\",\n ...idpConfigs.map(config => {\n // For built-in identity providers, we use the type as the name. Only for OIDC,\n // we allow the user to provide a custom name, and we only use the type as a fallback.\n if (config.providerType === \"OIDC\") {\n return config.providerName;\n }\n return config.providerType;\n })\n ]);\n\n /* Cognito writes the mapped attributes on every federated sign-in, so the app client must be\n allowed to write them. Note: this includes `custom:id`, which then also becomes writable by\n users through their own access token. */\n const mappedAttributes = idpConfigs.flatMap(config => {\n const mapping = (config.attributeMapping || {}) as Record<string, unknown>;\n return Object.keys(mapping).filter(name => name !== \"username\");\n });\n appClient.config.writeAttributes(\n getUserWritableAttributes(userPool.output.schemas).apply(attributes => {\n return [...new Set([...attributes, ...mappedAttributes])];\n })\n );\n\n appClient.config.allowedOauthScopes([\"profile\", \"email\", \"openid\"]);\n appClient.config.allowedOauthFlows([\"implicit\", \"code\"]);\n appClient.config.allowedOauthFlowsUserPoolClient(true);\n appClient.config.callbackUrls(config.callbackUrls);\n appClient.config.logoutUrls(config.logoutUrls ?? config.callbackUrls);\n};\n"],"names":["isString","value","configureAdminCognitoFederation","app","config","region","getEnvVariableAwsRegion","userPool","appClient","userPoolDomain","aws","undefined","pulumi","idpConfigs","idpOutputs","idp","getIdpConfig","name","idpResource","Array","mappedAttributes","mapping","Object","getUserWritableAttributes","attributes","Set"],"mappings":";;;;;AA0CA,MAAMA,WAAW,CAACC,QACP,AAAiB,YAAjB,OAAOA;AAGX,MAAMC,kCAAkC,CAC3CC,KACAC;IAEA,MAAMC,SAASC;IAEf,MAAMC,WAAWJ,IAAI,SAAS,CAAC,QAAQ;IAIvC,MAAMK,YAAYL,IAAI,SAAS,CAAC,cAAc;IAO9C,MAAMM,iBAAiBN,IAAI,WAAW,CAACO,uCAAAA,OAAAA,CAAAA,cAA0B,EAAE;QAC/D,MAAM;QACN,QAAQ;YACJ,QAAQV,SAASI,OAAO,MAAM,IAAIA,OAAO,MAAM,GAAGA,OAAO,MAAM,CAAC,IAAI;YACpE,gBAAgBJ,SAASI,OAAO,MAAM,IAAIO,SAAYP,OAAO,MAAM,CAAC,c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AC,OAAO,EAAE,KAAK,CAACiB,CAAAA,aAC9C;eAAI,IAAIC,IAAI;mBAAID;mBAAeJ;aAAiB;SAAE;IAIjEZ,UAAU,MAAM,CAAC,kBAAkB,CAAC;QAAC;QAAW;QAAS;KAAS;IAClEA,UAAU,MAAM,CAAC,iBAAiB,CAAC;QAAC;QAAY;KAAO;IACvDA,UAAU,MAAM,CAAC,+BAA+B,CAAC;IACjDA,UAAU,MAAM,CAAC,YAAY,CAACJ,OAAO,YAAY;IACjDI,UAAU,MAAM,CAAC,UAAU,CAACJ,OAAO,UAAU,IAAIA,OAAO,YAAY;AACxE"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { PulumiApp } from "@webiny/pulumi";
|
|
2
|
+
import { CoreDynamo } from "./CoreDynamo.js";
|
|
3
|
+
import { CoreAuditLogsDynamo } from "./CoreAuditLogsDynamo.js";
|
|
4
|
+
export interface CoreDynamoDbParams {
|
|
5
|
+
usesPostgres: boolean;
|
|
6
|
+
protect: boolean;
|
|
7
|
+
pointInTimeRecovery: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface CoreDynamoDbTables {
|
|
10
|
+
dynamoDbTable: CoreDynamo | undefined;
|
|
11
|
+
auditLogsDynamoDbTable: CoreAuditLogsDynamo | undefined;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The core's DynamoDB tables (the primary one and the audit logs one) and their stack outputs.
|
|
15
|
+
*
|
|
16
|
+
* With `<Infra.AuroraPostgres />` there are none: the API keeps all of its data, the service
|
|
17
|
+
* manifests included, in the database, so `<Infra.DynamoDb.Pitr />` has nothing to apply to either.
|
|
18
|
+
*/
|
|
19
|
+
export declare const addCoreDynamoDb: (app: PulumiApp, params: CoreDynamoDbParams) => CoreDynamoDbTables;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { CoreDynamo } from "./CoreDynamo.js";
|
|
2
|
+
import { CoreAuditLogsDynamo } from "./CoreAuditLogsDynamo.js";
|
|
3
|
+
const addCoreDynamoDb = (app, params)=>{
|
|
4
|
+
if (params.usesPostgres) return {
|
|
5
|
+
dynamoDbTable: void 0,
|
|
6
|
+
auditLogsDynamoDbTable: void 0
|
|
7
|
+
};
|
|
8
|
+
const { protect, pointInTimeRecovery } = params;
|
|
9
|
+
const dynamoDbTable = app.addModule(CoreDynamo, {
|
|
10
|
+
protect,
|
|
11
|
+
pointInTimeRecovery
|
|
12
|
+
});
|
|
13
|
+
const auditLogsDynamoDbTable = app.addModule(CoreAuditLogsDynamo, {
|
|
14
|
+
protect,
|
|
15
|
+
pointInTimeRecovery
|
|
16
|
+
});
|
|
17
|
+
app.addOutputs({
|
|
18
|
+
primaryDynamodbTableArn: dynamoDbTable.output.arn,
|
|
19
|
+
primaryDynamodbTableName: dynamoDbTable.output.name,
|
|
20
|
+
primaryDynamodbTableHashKey: dynamoDbTable.output.hashKey,
|
|
21
|
+
primaryDynamodbTableRangeKey: dynamoDbTable.output.rangeKey,
|
|
22
|
+
auditLogsDynamodbTableArn: auditLogsDynamoDbTable.output.arn,
|
|
23
|
+
auditLogsDynamodbTableName: auditLogsDynamoDbTable.output.name,
|
|
24
|
+
auditLogsDynamodbTableHashKey: auditLogsDynamoDbTable.output.hashKey,
|
|
25
|
+
auditLogsDynamodbTableRangeKey: auditLogsDynamoDbTable.output.rangeKey
|
|
26
|
+
});
|
|
27
|
+
return {
|
|
28
|
+
dynamoDbTable,
|
|
29
|
+
auditLogsDynamoDbTable
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export { addCoreDynamoDb };
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=coreDynamoDb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pulumi/apps/core/coreDynamoDb.js","sources":["../../../../src/pulumi/apps/core/coreDynamoDb.ts"],"sourcesContent":["import type { PulumiApp } from \"@webiny/pulumi\";\nimport { CoreDynamo } from \"./CoreDynamo.js\";\nimport { CoreAuditLogsDynamo } from \"./CoreAuditLogsDynamo.js\";\n\nexport interface CoreDynamoDbParams {\n /* The project has `<Infra.AuroraPostgres />`. */\n usesPostgres: boolean;\n protect: boolean;\n pointInTimeRecovery: boolean;\n}\n\nexport interface CoreDynamoDbTables {\n /* Not created with `<Infra.AuroraPostgres />`. */\n dynamoDbTable: CoreDynamo | undefined;\n /* Not created with `<Infra.AuroraPostgres />`. */\n auditLogsDynamoDbTable: CoreAuditLogsDynamo | undefined;\n}\n\n/**\n * The core's DynamoDB tables (the primary one and the audit logs one) and their stack outputs.\n *\n * With `<Infra.AuroraPostgres />` there are none: the API keeps all of its data, the service\n * manifests included, in the database, so `<Infra.DynamoDb.Pitr />` has nothing to apply to either.\n */\nexport const addCoreDynamoDb = (app: PulumiApp, params: CoreDynamoDbParams): CoreDynamoDbTables => {\n if (params.usesPostgres) {\n return { dynamoDbTable: undefined, auditLogsDynamoDbTable: undefined };\n }\n\n const { protect, pointInTimeRecovery } = params;\n const dynamoDbTable = app.addModule(CoreDynamo, { protect, pointInTimeRecovery });\n const auditLogsDynamoDbTable = app.addModule(CoreAuditLogsDynamo, {\n protect,\n pointInTimeRecovery\n });\n\n app.addOutputs({\n primaryDynamodbTableArn: dynamoDbTable.output.arn,\n primaryDynamodbTableName: dynamoDbTable.output.name,\n primaryDynamodbTableHashKey: dynamoDbTable.output.hashKey,\n primaryDynamodbTableRangeKey: dynamoDbTable.output.rangeKey,\n auditLogsDynamodbTableArn: auditLogsDynamoDbTable.output.arn,\n auditLogsDynamodbTableName: auditLogsDynamoDbTable.output.name,\n auditLogsDynamodbTableHashKey: auditLogsDynamoDbTable.output.hashKey,\n auditLogsDynamodbTableRangeKey: auditLogsDynamoDbTable.output.rangeKey\n });\n\n return { dynamoDbTable, auditLogsDynamoDbTable };\n};\n"],"names":["addCoreDynamoDb","app","params","undefined","protect","pointInTimeRecovery","dynamoDbTable","CoreDynamo","auditLogsDynamoDbTable","CoreAuditLogsDynamo"],"mappings":";;AAwBO,MAAMA,kBAAkB,CAACC,KAAgBC;IAC5C,IAAIA,OAAO,YAAY,EACnB,OAAO;QAAE,eAAeC;QAAW,wBAAwBA;IAAU;IAGzE,MAAM,EAAEC,OAAO,EAAEC,mBAAmB,EAAE,GAAGH;IACzC,MAAMI,gBAAgBL,IAAI,SAAS,CAACM,YAAY;QAAEH;QAASC;IAAoB;IAC/E,MAAMG,yBAAyBP,IAAI,SAAS,CAACQ,qBAAqB;QAC9DL;QACAC;IACJ;IAEAJ,IAAI,UAAU,CAAC;QACX,yBAAyBK,cAAc,MAAM,CAAC,GAAG;QACjD,0BAA0BA,cAAc,MAAM,CAAC,IAAI;QACnD,6BAA6BA,cAAc,MAAM,CAAC,OAAO;QACzD,8BAA8BA,cAAc,MAAM,CAAC,QAAQ;QAC3D,2BAA2BE,uBAAuB,MAAM,CAAC,GAAG;QAC5D,4BAA4BA,uBAAuB,MAAM,CAAC,IAAI;QAC9D,+BAA+BA,uBAAuB,MAAM,CAAC,OAAO;QACpE,gCAAgCA,uBAAuB,MAAM,CAAC,QAAQ;IAC1E;IAEA,OAAO;QAAEF;QAAeE;IAAuB;AACnD"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as pulumi from "@pulumi/pulumi";
|
|
2
|
+
import type { PulumiApp } from "@webiny/pulumi";
|
|
3
|
+
import type { ServiceManifest } from "../../../pulumi/utils/addServiceManifestTableItem.js";
|
|
4
|
+
/**
|
|
5
|
+
* The core stack output that carries the core's service manifests, with `<Infra.AuroraPostgres />`.
|
|
6
|
+
*/
|
|
7
|
+
export declare const CORE_SERVICE_MANIFESTS_OUTPUT = "serviceManifests";
|
|
8
|
+
export interface CoreServiceManifestParams {
|
|
9
|
+
eventBus: {
|
|
10
|
+
output: {
|
|
11
|
+
arn: pulumi.Output<string>;
|
|
12
|
+
name: pulumi.Output<string>;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
dynamoDbTable?: {
|
|
16
|
+
output: {
|
|
17
|
+
arn: pulumi.Output<string>;
|
|
18
|
+
name: pulumi.Output<string>;
|
|
19
|
+
hashKey: pulumi.Output<string>;
|
|
20
|
+
rangeKey: pulumi.Output<string | undefined>;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/** The `core` service manifest: the event bus, and the primary DynamoDB table when there is one. */
|
|
25
|
+
export declare const createCoreServiceManifest: (params: CoreServiceManifestParams) => ServiceManifest;
|
|
26
|
+
/**
|
|
27
|
+
* With `<Infra.AuroraPostgres />`: puts the core's service manifests in its stack output. The core
|
|
28
|
+
* deploys before the api's schema-setup function exists, and the database is in private subnets the
|
|
29
|
+
* deploy can't reach, so the api deploy passes them on to the schema setup, which stores them.
|
|
30
|
+
*/
|
|
31
|
+
export declare const addServiceManifestsOutput: (app: PulumiApp, manifests: ServiceManifest[]) => void;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as __rspack_external__pulumi_pulumi_f3e773ed from "@pulumi/pulumi";
|
|
2
|
+
const CORE_SERVICE_MANIFESTS_OUTPUT = "serviceManifests";
|
|
3
|
+
const createCoreServiceManifest = (params)=>{
|
|
4
|
+
const { eventBus, dynamoDbTable } = params;
|
|
5
|
+
return {
|
|
6
|
+
name: "core",
|
|
7
|
+
manifest: {
|
|
8
|
+
eventBus: {
|
|
9
|
+
arn: eventBus.output.arn,
|
|
10
|
+
name: eventBus.output.name
|
|
11
|
+
},
|
|
12
|
+
...dynamoDbTable && {
|
|
13
|
+
dynamodbTable: {
|
|
14
|
+
arn: dynamoDbTable.output.arn,
|
|
15
|
+
name: dynamoDbTable.output.name,
|
|
16
|
+
hashKey: dynamoDbTable.output.hashKey,
|
|
17
|
+
rangeKey: dynamoDbTable.output.rangeKey
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
const addServiceManifestsOutput = (app, manifests)=>{
|
|
24
|
+
app.addOutput(CORE_SERVICE_MANIFESTS_OUTPUT, __rspack_external__pulumi_pulumi_f3e773ed.output(manifests.map(({ name, manifest })=>({
|
|
25
|
+
name,
|
|
26
|
+
manifest
|
|
27
|
+
}))));
|
|
28
|
+
};
|
|
29
|
+
export { CORE_SERVICE_MANIFESTS_OUTPUT, addServiceManifestsOutput, createCoreServiceManifest };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=coreServiceManifests.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pulumi/apps/core/coreServiceManifests.js","sources":["../../../../src/pulumi/apps/core/coreServiceManifests.ts"],"sourcesContent":["import * as pulumi from \"@pulumi/pulumi\";\nimport type { PulumiApp } from \"@webiny/pulumi\";\nimport type { ServiceManifest } from \"~/pulumi/utils/addServiceManifestTableItem.js\";\n\n/**\n * The core stack output that carries the core's service manifests, with `<Infra.AuroraPostgres />`.\n */\nexport const CORE_SERVICE_MANIFESTS_OUTPUT = \"serviceManifests\";\n\nexport interface CoreServiceManifestParams {\n eventBus: {\n output: { arn: pulumi.Output<string>; name: pulumi.Output<string> };\n };\n /* The primary DynamoDB table. Not in the manifest with `<Infra.AuroraPostgres />`. */\n dynamoDbTable?: {\n output: {\n arn: pulumi.Output<string>;\n name: pulumi.Output<string>;\n hashKey: pulumi.Output<string>;\n rangeKey: pulumi.Output<string | undefined>;\n };\n };\n}\n\n/** The `core` service manifest: the event bus, and the primary DynamoDB table when there is one. */\nexport const createCoreServiceManifest = (params: CoreServiceManifestParams): ServiceManifest => {\n const { eventBus, dynamoDbTable } = params;\n return {\n name: \"core\",\n manifest: {\n eventBus: {\n arn: eventBus.output.arn,\n name: eventBus.output.name\n },\n ...(dynamoDbTable && {\n dynamodbTable: {\n arn: dynamoDbTable.output.arn,\n name: dynamoDbTable.output.name,\n hashKey: dynamoDbTable.output.hashKey,\n rangeKey: dynamoDbTable.output.rangeKey\n }\n })\n }\n };\n};\n\n/**\n * With `<Infra.AuroraPostgres />`: puts the core's service manifests in its stack output. The core\n * deploys before the api's schema-setup function exists, and the database is in private subnets the\n * deploy can't reach, so the api deploy passes them on to the schema setup, which stores them.\n */\nexport const addServiceManifestsOutput = (app: PulumiApp, manifests: ServiceManifest[]) => {\n app.addOutput(\n CORE_SERVICE_MANIFESTS_OUTPUT,\n pulumi.output(manifests.map(({ name, manifest }) => ({ name, manifest })))\n );\n};\n"],"names":["CORE_SERVICE_MANIFESTS_OUTPUT","createCoreServiceManifest","params","eventBus","dynamoDbTable","addServiceManifestsOutput","app","manifests","pulumi","name","manifest"],"mappings":";AAOO,MAAMA,gCAAgC;AAkBtC,MAAMC,4BAA4B,CAACC;IACtC,MAAM,EAAEC,QAAQ,EAAEC,aAAa,EAAE,GAAGF;IACpC,OAAO;QACH,MAAM;QACN,UAAU;YACN,UAAU;gBACN,KAAKC,SAAS,MAAM,CAAC,GAAG;gBACxB,MAAMA,SAAS,MAAM,CAAC,IAAI;YAC9B;YACA,GAAIC,iBAAiB;gBACjB,eAAe;oBACX,KAAKA,cAAc,MAAM,CAAC,GAAG;oBAC7B,MAAMA,cAAc,MAAM,CAAC,IAAI;oBAC/B,SAASA,cAAc,MAAM,CAAC,OAAO;oBACrC,UAAUA,cAAc,MAAM,CAAC,QAAQ;gBAC3C;YACJ,CAAC;QACL;IACJ;AACJ;AAOO,MAAMC,4BAA4B,CAACC,KAAgBC;IACtDD,IAAI,SAAS,CACTN,+BACAQ,0CAAAA,MAAa,CAACD,UAAU,GAAG,CAAC,CAAC,EAAEE,IAAI,EAAEC,QAAQ,EAAE,GAAM;YAAED;YAAMC;QAAS;AAE9E"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as pulumi from "@pulumi/pulumi";
|
|
2
|
+
import type { PulumiApp } from "@webiny/pulumi";
|
|
3
|
+
import type { CoreVpc } from "./CoreVpc.js";
|
|
4
|
+
export interface CoreVpcEndpointsParams {
|
|
5
|
+
vpc: Pick<CoreVpc, "vpc" | "subnets" | "routeTables">;
|
|
6
|
+
region: pulumi.Input<string>;
|
|
7
|
+
usesPostgres: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The VPC endpoints of `<Infra.Vpc useVpcEndpoints />`: gateways for S3 and DynamoDB, interfaces for
|
|
11
|
+
* SQS and EventBridge. With `<Infra.AuroraPostgres />` there's no DynamoDB endpoint: nothing in the
|
|
12
|
+
* VPC talks to DynamoDB.
|
|
13
|
+
*/
|
|
14
|
+
export declare const addCoreVpcEndpoints: (app: PulumiApp, params: CoreVpcEndpointsParams) => void;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as __rspack_external__pulumi_aws_9e2bee2d from "@pulumi/aws";
|
|
2
|
+
import * as __rspack_external__pulumi_pulumi_f3e773ed from "@pulumi/pulumi";
|
|
3
|
+
const addCoreVpcEndpoints = (app, params)=>{
|
|
4
|
+
const { vpc, subnets, routeTables } = params.vpc;
|
|
5
|
+
const { region } = params;
|
|
6
|
+
app.addResource(__rspack_external__pulumi_aws_9e2bee2d.ec2.VpcEndpoint, {
|
|
7
|
+
name: "vpc-s3-vpc-endpoint",
|
|
8
|
+
config: {
|
|
9
|
+
vpcId: vpc.output.id,
|
|
10
|
+
serviceName: __rspack_external__pulumi_pulumi_f3e773ed.interpolate`com.amazonaws.${region}.s3`,
|
|
11
|
+
routeTableIds: [
|
|
12
|
+
routeTables.privateSubnets.output.id
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
if (!params.usesPostgres) app.addResource(__rspack_external__pulumi_aws_9e2bee2d.ec2.VpcEndpoint, {
|
|
17
|
+
name: "vpc-dynamodb-vpc-endpoint",
|
|
18
|
+
config: {
|
|
19
|
+
vpcId: vpc.output.id,
|
|
20
|
+
serviceName: __rspack_external__pulumi_pulumi_f3e773ed.interpolate`com.amazonaws.${region}.dynamodb`,
|
|
21
|
+
routeTableIds: [
|
|
22
|
+
routeTables.privateSubnets.output.id
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
app.addResource(__rspack_external__pulumi_aws_9e2bee2d.ec2.VpcEndpoint, {
|
|
27
|
+
name: "vpc-sqs-vpc-endpoint",
|
|
28
|
+
config: {
|
|
29
|
+
vpcId: vpc.output.id,
|
|
30
|
+
serviceName: __rspack_external__pulumi_pulumi_f3e773ed.interpolate`com.amazonaws.${region}.sqs`,
|
|
31
|
+
vpcEndpointType: "Interface",
|
|
32
|
+
privateDnsEnabled: true,
|
|
33
|
+
securityGroupIds: [
|
|
34
|
+
vpc.output.defaultSecurityGroupId
|
|
35
|
+
],
|
|
36
|
+
subnetIds: subnets.private.map((subNet)=>subNet.output.id)
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
app.addResource(__rspack_external__pulumi_aws_9e2bee2d.ec2.VpcEndpoint, {
|
|
40
|
+
name: "vpc-events-vpc-endpoint",
|
|
41
|
+
config: {
|
|
42
|
+
vpcId: vpc.output.id,
|
|
43
|
+
serviceName: __rspack_external__pulumi_pulumi_f3e773ed.interpolate`com.amazonaws.${region}.events`,
|
|
44
|
+
vpcEndpointType: "Interface",
|
|
45
|
+
privateDnsEnabled: true,
|
|
46
|
+
securityGroupIds: [
|
|
47
|
+
vpc.output.defaultSecurityGroupId
|
|
48
|
+
],
|
|
49
|
+
subnetIds: subnets.private.map((subNet)=>subNet.output.id)
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
export { addCoreVpcEndpoints };
|
|
54
|
+
|
|
55
|
+
//# sourceMappingURL=coreVpcEndpoints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pulumi/apps/core/coreVpcEndpoints.js","sources":["../../../../src/pulumi/apps/core/coreVpcEndpoints.ts"],"sourcesContent":["import * as aws from \"@pulumi/aws\";\nimport * as pulumi from \"@pulumi/pulumi\";\nimport type { PulumiApp } from \"@webiny/pulumi\";\nimport type { CoreVpc } from \"./CoreVpc.js\";\n\nexport interface CoreVpcEndpointsParams {\n vpc: Pick<CoreVpc, \"vpc\" | \"subnets\" | \"routeTables\">;\n region: pulumi.Input<string>;\n /* The project has `<Infra.AuroraPostgres />`. */\n usesPostgres: boolean;\n}\n\n/**\n * The VPC endpoints of `<Infra.Vpc useVpcEndpoints />`: gateways for S3 and DynamoDB, interfaces for\n * SQS and EventBridge. With `<Infra.AuroraPostgres />` there's no DynamoDB endpoint: nothing in the\n * VPC talks to DynamoDB.\n */\nexport const addCoreVpcEndpoints = (app: PulumiApp, params: CoreVpcEndpointsParams) => {\n const { vpc, subnets, routeTables } = params.vpc;\n const { region } = params;\n\n app.addResource(aws.ec2.VpcEndpoint, {\n name: \"vpc-s3-vpc-endpoint\",\n config: {\n vpcId: vpc.output.id,\n serviceName: pulumi.interpolate`com.amazonaws.${region}.s3`,\n routeTableIds: [routeTables.privateSubnets.output.id]\n }\n });\n\n if (!params.usesPostgres) {\n app.addResource(aws.ec2.VpcEndpoint, {\n name: \"vpc-dynamodb-vpc-endpoint\",\n config: {\n vpcId: vpc.output.id,\n serviceName: pulumi.interpolate`com.amazonaws.${region}.dynamodb`,\n routeTableIds: [routeTables.privateSubnets.output.id]\n }\n });\n }\n\n app.addResource(aws.ec2.VpcEndpoint, {\n name: \"vpc-sqs-vpc-endpoint\",\n config: {\n vpcId: vpc.output.id,\n serviceName: pulumi.interpolate`com.amazonaws.${region}.sqs`,\n vpcEndpointType: \"Interface\",\n privateDnsEnabled: true,\n securityGroupIds: [vpc.output.defaultSecurityGroupId],\n subnetIds: subnets.private.map(subNet => subNet.output.id)\n }\n });\n\n app.addResource(aws.ec2.VpcEndpoint, {\n name: \"vpc-events-vpc-endpoint\",\n config: {\n vpcId: vpc.output.id,\n serviceName: pulumi.interpolate`com.amazonaws.${region}.events`,\n vpcEndpointType: \"Interface\",\n privateDnsEnabled: true,\n securityGroupIds: [vpc.output.defaultSecurityGroupId],\n subnetIds: subnets.private.map(subNet => subNet.output.id)\n }\n });\n};\n"],"names":["addCoreVpcEndpoints","app","params","vpc","subnets","routeTables","region","aws","pulumi","subNet"],"mappings":";;AAiBO,MAAMA,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Ac,EAAEF,OAAO,OAAO,CAAC;YAC/D,iBAAiB;YACjB,mBAAmB;YACnB,kBAAkB;gBAACH,IAAI,MAAM,CAAC,sBAAsB;aAAC;YACrD,WAAWC,QAAQ,OAAO,CAAC,GAAG,CAACK,CAAAA,SAAUA,OAAO,MAAM,CAAC,EAAE;QAC7D;IACJ;AACJ"}
|
|
@@ -3,7 +3,7 @@ export type CorePulumiApp = ReturnType<typeof createCorePulumiApp>;
|
|
|
3
3
|
export declare function createCorePulumiApp(): import("@webiny/pulumi").PulumiApp<{
|
|
4
4
|
userPool: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/cognito/userPool.js").UserPool>;
|
|
5
5
|
userPoolClient: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/cognito/userPoolClient.js").UserPoolClient>;
|
|
6
|
-
dynamoDbTable: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/dynamodb/table.js").Table
|
|
6
|
+
dynamoDbTable: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/dynamodb/table.js").Table> | undefined;
|
|
7
7
|
vpc: {
|
|
8
8
|
vpc: import("@webiny/pulumi").PulumiAppResource<typeof import("@pulumi/aws/ec2/vpc.js").Vpc>;
|
|
9
9
|
subnets: {
|