@appliance.sh/install-aws 1.5.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/CHANGELOG.md +24 -0
- package/cdk.json +3 -0
- package/docker/Dockerfile +3 -0
- package/package.json +22 -0
- package/scripts/postbuild.ts +29 -0
- package/src/index.ts +25 -0
- package/src/lib/ApplianceApiStackV1.ts +53 -0
- package/src/lib/ApplianceGlobalStackV1.ts +72 -0
- package/src/version.ts +1 -0
- package/tsconfig.json +10 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
## 1.5.0 (2025-12-15)
|
|
2
|
+
|
|
3
|
+
### 🚀 Features
|
|
4
|
+
|
|
5
|
+
- add cdk experimental stacks ([#8](https://github.com/appliance-sh/appliance.sh/pull/8))
|
|
6
|
+
- **api-server:** init nest project ([#7](https://github.com/appliance-sh/appliance.sh/pull/7))
|
|
7
|
+
|
|
8
|
+
### 🩹 Fixes
|
|
9
|
+
|
|
10
|
+
- package repository url again ([#19](https://github.com/appliance-sh/appliance.sh/pull/19))
|
|
11
|
+
- package repository url ([#18](https://github.com/appliance-sh/appliance.sh/pull/18))
|
|
12
|
+
- nx release projects ([#17](https://github.com/appliance-sh/appliance.sh/pull/17))
|
|
13
|
+
- nx release groups ([#16](https://github.com/appliance-sh/appliance.sh/pull/16))
|
|
14
|
+
- npm package public again ([#15](https://github.com/appliance-sh/appliance.sh/pull/15))
|
|
15
|
+
- npm package public ([#14](https://github.com/appliance-sh/appliance.sh/pull/14))
|
|
16
|
+
- release node setup ([#13](https://github.com/appliance-sh/appliance.sh/pull/13))
|
|
17
|
+
- release npm ([#12](https://github.com/appliance-sh/appliance.sh/pull/12))
|
|
18
|
+
- nx release ci again ([#11](https://github.com/appliance-sh/appliance.sh/pull/11))
|
|
19
|
+
- nx release ci ([#10](https://github.com/appliance-sh/appliance.sh/pull/10))
|
|
20
|
+
- nx workspaces and packages ([#9](https://github.com/appliance-sh/appliance.sh/pull/9))
|
|
21
|
+
|
|
22
|
+
### ❤️ Thank You
|
|
23
|
+
|
|
24
|
+
- Eliot Lim @eliotlim
|
package/cdk.json
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@appliance.sh/install-aws",
|
|
3
|
+
"version": "1.5.0",
|
|
4
|
+
"description": "Install the Appliance platform on AWS",
|
|
5
|
+
"repository": "https://github.com/appliance-sh/appliance.sh",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "Eliot Lim",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "mkdir -p ./dist && cdk synth > dist/appliance-install-aws.yml",
|
|
10
|
+
"clean": "rm -rf ./dist/",
|
|
11
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@appliance.sh/sdk": "1.5.0",
|
|
15
|
+
"aws-cdk": "^2.1033.0",
|
|
16
|
+
"aws-cdk-lib": "^2.230.0",
|
|
17
|
+
"constructs": "^10.4.3"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@types/node": "^24.0.1"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { execSync } from 'child_process';
|
|
2
|
+
import { readFileSync, writeFileSync } from 'fs';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
|
|
5
|
+
const updateVersion = (filePath: string, version: string): void => {
|
|
6
|
+
const fileContent = readFileSync(filePath, 'utf8');
|
|
7
|
+
const updatedContent = fileContent.replace(/0\.0\.0-semantically-released/g, version);
|
|
8
|
+
writeFileSync(filePath, updatedContent, 'utf8');
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const main = (): void => {
|
|
12
|
+
try {
|
|
13
|
+
// Get the latest Git tag
|
|
14
|
+
const latestTag = execSync('git describe --tags --abbrev=0').toString().trim();
|
|
15
|
+
|
|
16
|
+
// Define file paths to update
|
|
17
|
+
const filesToUpdate = [join(__dirname, '../dist/cjs/version.js'), join(__dirname, '../dist/esm/version.js')];
|
|
18
|
+
|
|
19
|
+
// Update version in each file
|
|
20
|
+
filesToUpdate.forEach((filePath) => updateVersion(filePath, latestTag));
|
|
21
|
+
|
|
22
|
+
console.log(`Version updated to ${latestTag} in files:`, filesToUpdate);
|
|
23
|
+
} catch (error) {
|
|
24
|
+
console.error('Error updating version:', error);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
main();
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env ts-node
|
|
2
|
+
|
|
3
|
+
export * from './version';
|
|
4
|
+
|
|
5
|
+
import 'source-map-support/register';
|
|
6
|
+
import * as cdk from 'aws-cdk-lib';
|
|
7
|
+
import { ApplianceApiStackV1 } from './lib/ApplianceApiStackV1';
|
|
8
|
+
import { ApplianceGlobalStackV1 } from './lib/ApplianceGlobalStackV1';
|
|
9
|
+
|
|
10
|
+
const app = new cdk.App();
|
|
11
|
+
|
|
12
|
+
const name = 'stack';
|
|
13
|
+
const stackId = `appliance-api-${name}`;
|
|
14
|
+
|
|
15
|
+
const globalStack = new ApplianceGlobalStackV1(app, `${stackId}-global`, {
|
|
16
|
+
env: { account: process.env.CDK_DEFAULT_ACCOUNT, region: 'us-east-1' },
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
if (!globalStack.hostedZone) throw new Error('Global stack not deployed');
|
|
20
|
+
|
|
21
|
+
new ApplianceApiStackV1(app, stackId, {
|
|
22
|
+
env: { account: process.env.CDK_DEFAULT_ACCOUNT, region: process.env.CDK_DEFAULT_REGION },
|
|
23
|
+
crossRegionReferences: true,
|
|
24
|
+
hostedZone: globalStack.hostedZone,
|
|
25
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import * as cdk from 'aws-cdk-lib';
|
|
2
|
+
import { Construct } from 'constructs';
|
|
3
|
+
|
|
4
|
+
interface ApplianceApiStackV1Props extends cdk.StackProps {
|
|
5
|
+
hostedZone: cdk.aws_route53.PublicHostedZone;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export class ApplianceApiStackV1 extends cdk.Stack {
|
|
9
|
+
public apiLambda;
|
|
10
|
+
public apiLambdaUrl;
|
|
11
|
+
public localCertificate;
|
|
12
|
+
|
|
13
|
+
constructor(scope: Construct, id: string, props: ApplianceApiStackV1Props) {
|
|
14
|
+
super(scope, id, props);
|
|
15
|
+
|
|
16
|
+
const stages = {
|
|
17
|
+
stage1: true, // Permanent constructs, like the DNS zone, VPC, and IAM roles
|
|
18
|
+
stage2: true,
|
|
19
|
+
stage3: true,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const domainName = 'appliance.sh';
|
|
23
|
+
|
|
24
|
+
if (stages.stage2) {
|
|
25
|
+
const apiLambdaEcr = new cdk.aws_ecr.Repository(this, `${id}`, {
|
|
26
|
+
repositoryName: `${id}`,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
this.apiLambda = new cdk.aws_lambda.Function(this, `${id}-api-server`, {
|
|
30
|
+
runtime: cdk.aws_lambda.Runtime.NODEJS_24_X,
|
|
31
|
+
handler: 'index.handler',
|
|
32
|
+
code: cdk.aws_lambda.Code.fromInline(`exports.handler = async () => "Hello ${'ap-southeast-1'}!";`),
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
this.apiLambdaUrl = this.apiLambda.addFunctionUrl({
|
|
36
|
+
authType: cdk.aws_lambda.FunctionUrlAuthType.AWS_IAM,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// Output the ECR URI
|
|
40
|
+
new cdk.CfnOutput(this, `${id}-image-uri`, {
|
|
41
|
+
value: apiLambdaEcr.repositoryUri,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (stages.stage3 && props.hostedZone && this.apiLambdaUrl) {
|
|
46
|
+
this.localCertificate = new cdk.aws_certificatemanager.Certificate(this, `${id}-certificate`, {
|
|
47
|
+
domainName: `*.${domainName}`,
|
|
48
|
+
validation: cdk.aws_certificatemanager.CertificateValidation.fromDns(props.hostedZone),
|
|
49
|
+
subjectAlternativeNames: [`*.${domainName}`],
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import * as cdk from 'aws-cdk-lib';
|
|
2
|
+
import { Construct } from 'constructs';
|
|
3
|
+
|
|
4
|
+
export class ApplianceGlobalStackV1 extends cdk.Stack {
|
|
5
|
+
public hostedZone;
|
|
6
|
+
public apiLambda;
|
|
7
|
+
public apiLambdaUrl;
|
|
8
|
+
public globalCertificate;
|
|
9
|
+
public cfDistribution;
|
|
10
|
+
|
|
11
|
+
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
|
|
12
|
+
super(scope, id, props);
|
|
13
|
+
|
|
14
|
+
const stages = {
|
|
15
|
+
stage1: true, // Permanent constructs, like the DNS zone, VPC, and IAM roles
|
|
16
|
+
stage2: true,
|
|
17
|
+
stage3: true,
|
|
18
|
+
stage4: true,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const domainName = 'appliance.sh';
|
|
22
|
+
|
|
23
|
+
if (stages.stage1) {
|
|
24
|
+
this.hostedZone = new cdk.aws_route53.PublicHostedZone(this, `${id}-zone`, {
|
|
25
|
+
zoneName: domainName,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
new cdk.CfnOutput(this, `${id}-zone-name`, {
|
|
29
|
+
value: this.hostedZone.zoneName,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (stages.stage2 && this.hostedZone) {
|
|
34
|
+
this.globalCertificate = new cdk.aws_certificatemanager.Certificate(this, `${id}-certificate`, {
|
|
35
|
+
domainName: `*.${domainName}`,
|
|
36
|
+
validation: cdk.aws_certificatemanager.CertificateValidation.fromDns(this.hostedZone),
|
|
37
|
+
subjectAlternativeNames: [`*.${domainName}`],
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (stages.stage3 && this.globalCertificate) {
|
|
42
|
+
this.apiLambda = new cdk.aws_lambda.Function(this, `${id}-api-server`, {
|
|
43
|
+
runtime: cdk.aws_lambda.Runtime.NODEJS_24_X,
|
|
44
|
+
handler: 'index.handler',
|
|
45
|
+
code: cdk.aws_lambda.Code.fromInline('exports.handler = async () => "Hello World!";'),
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
this.apiLambdaUrl = this.apiLambda.addFunctionUrl({
|
|
49
|
+
authType: cdk.aws_lambda.FunctionUrlAuthType.AWS_IAM,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
this.cfDistribution = new cdk.aws_cloudfront.Distribution(this, `${id}-distribution`, {
|
|
53
|
+
domainNames: [`*.${domainName}`],
|
|
54
|
+
certificate: this.globalCertificate,
|
|
55
|
+
defaultBehavior: {
|
|
56
|
+
origin: cdk.aws_cloudfront_origins.FunctionUrlOrigin.withOriginAccessControl(this.apiLambdaUrl),
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
new cdk.CfnOutput(this, `${id}-distribution-domain`, { value: this.cfDistribution.distributionDomainName });
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (stages.stage4 && this.hostedZone && this.cfDistribution) {
|
|
64
|
+
new cdk.aws_route53.CnameRecord(this, `${id}-cname`, {
|
|
65
|
+
zone: this.hostedZone,
|
|
66
|
+
recordName: `api.${domainName}`,
|
|
67
|
+
domainName: this.cfDistribution.distributionDomainName,
|
|
68
|
+
ttl: cdk.Duration.minutes(5),
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
package/src/version.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const VERSION = '0.0.0-semantically-released';
|