@appliance.sh/api-server 1.7.0 → 1.9.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appliance.sh/api-server",
3
- "version": "1.7.0",
3
+ "version": "1.9.0",
4
4
  "description": "",
5
5
  "author": "Eliot Lim",
6
6
  "repository": "https://github.com/appliance-sh/appliance.sh",
@@ -23,8 +23,8 @@
23
23
  "@nestjs/common": "^11.0.1",
24
24
  "@nestjs/core": "^11.0.1",
25
25
  "@nestjs/platform-express": "^11.0.1",
26
- "@pulumi/aws": "^6.56.0",
27
- "@pulumi/pulumi": "^3.150.0",
26
+ "@pulumi/aws": "^7.15.0",
27
+ "@pulumi/pulumi": "^3.213.0",
28
28
  "reflect-metadata": "^0.2.2",
29
29
  "rxjs": "^7.8.1"
30
30
  },
@@ -0,0 +1,86 @@
1
+ import * as pulumi from '@pulumi/pulumi';
2
+ import * as aws from '@pulumi/aws';
3
+
4
+ export interface ApplianceStackArgs {
5
+ tags?: Record<string, string>;
6
+ }
7
+
8
+ export interface ApplianceStackOpts extends pulumi.ComponentResourceOptions {
9
+ globalProvider: aws.Provider;
10
+ provider: aws.Provider;
11
+ }
12
+
13
+ export class ApplianceStack extends pulumi.ComponentResource {
14
+ lambdaRole: aws.iam.Role;
15
+ lambdaRolePolicy: aws.iam.Policy;
16
+ lambda: aws.lambda.Function;
17
+ lambdaUrl: aws.lambda.FunctionUrl;
18
+
19
+ constructor(name: string, args: ApplianceStackArgs, opts: ApplianceStackOpts) {
20
+ super('appliance:aws:ApplianceStack', name, args, opts);
21
+
22
+ const defaultOpts = { parent: this, provider: opts.provider };
23
+ const defaultTags = { stack: name, managed: 'appliance', ...args.tags };
24
+
25
+ this.lambdaRole = new aws.iam.Role(`${name}-role`, {
26
+ path: `/appliance/${name}/`,
27
+ assumeRolePolicy: aws.iam.assumeRolePolicyForPrincipal({ Service: 'lambda.amazonaws.com' }),
28
+ tags: defaultTags,
29
+ });
30
+
31
+ this.lambdaRolePolicy = new aws.iam.Policy(`${name}-policy`, {
32
+ path: `/appliance/${name}/`,
33
+ policy: {
34
+ Version: '2012-10-17',
35
+ Statement: [{ Effect: 'Allow', Action: 'logs:CreateLogGroup', Resource: '*' }],
36
+ },
37
+ });
38
+
39
+ new aws.iam.RolePolicyAttachment(`${name}-role-policy-attachment`, {
40
+ role: this.lambdaRole.name,
41
+ policyArn: this.lambdaRolePolicy.arn,
42
+ });
43
+
44
+ this.lambda = new aws.lambda.CallbackFunction(
45
+ `${name}-handler`,
46
+ {
47
+ runtime: 'nodejs22.x',
48
+ callback: async () => {
49
+ return { statusCode: 200, body: JSON.stringify({ message: 'Hello world!' }) };
50
+ },
51
+ tags: defaultTags,
52
+ },
53
+ defaultOpts
54
+ );
55
+
56
+ // lambda url
57
+ this.lambdaUrl = new aws.lambda.FunctionUrl(
58
+ `${name}-url`,
59
+ {
60
+ functionName: this.lambda.name,
61
+ authorizationType: 'NONE',
62
+ },
63
+ defaultOpts
64
+ );
65
+
66
+ new aws.lambda.Permission(`${name}-url-invoke-url-permission`, {
67
+ function: this.lambda.name,
68
+ action: 'lambda:InvokeFunctionUrl',
69
+ principal: '*',
70
+ functionUrlAuthType: 'NONE',
71
+ statementId: 'FunctionURLAllowPublicAccess',
72
+ });
73
+
74
+ new aws.lambda.Permission(`${name}-url-invoke-lambda-permission`, {
75
+ function: this.lambda.name,
76
+ action: 'lambda:InvokeFunction',
77
+ principal: '*',
78
+ statementId: 'FunctionURLAllowInvokeAction',
79
+ });
80
+
81
+ this.registerOutputs({
82
+ lambda: this.lambda,
83
+ lambdaUrl: this.lambdaUrl,
84
+ });
85
+ }
86
+ }
@@ -3,6 +3,7 @@ import * as path from 'node:path';
3
3
  import * as fs from 'node:fs';
4
4
  import * as auto from '@pulumi/pulumi/automation';
5
5
  import * as aws from '@pulumi/aws';
6
+ import { ApplianceStack } from './ApplianceStack';
6
7
 
7
8
  export type PulumiAction = 'deploy' | 'destroy';
8
9
 
@@ -28,12 +29,32 @@ export class PulumiService {
28
29
 
29
30
  private inlineProgram() {
30
31
  return async () => {
32
+ const name = 'appliance';
33
+ const regionalProvider = new aws.Provider(`${name}-regional`, {
34
+ region: 'ap-southeast-1',
35
+ });
36
+ const globalProvider = new aws.Provider(`${name}-global`, {
37
+ region: 'us-east-1',
38
+ });
39
+
40
+ const applianceStack = new ApplianceStack(
41
+ `${name}-stack`,
42
+ {
43
+ tags: { project: name },
44
+ },
45
+ {
46
+ globalProvider,
47
+ provider: regionalProvider,
48
+ }
49
+ );
50
+
31
51
  const bucket = new aws.s3.Bucket('dummy-bucket', {
32
52
  forceDestroy: true,
33
53
  versioning: { enabled: true },
34
54
  tags: { app: 'appliance-api' },
35
55
  });
36
56
  return {
57
+ applianceStack,
37
58
  bucketName: bucket.bucket,
38
59
  };
39
60
  };