stacktape 3.5.7 → 3.6.0-beta.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/.tsconfig.bun-build.json +1 -0
- package/ai-docs/cli-ref/aws-profile-create.md +22 -0
- package/ai-docs/cli-ref/aws-profile-delete.md +22 -0
- package/ai-docs/cli-ref/aws-profile-list.md +20 -0
- package/ai-docs/cli-ref/aws-profile-update.md +22 -0
- package/ai-docs/cli-ref/bastion-session.md +29 -0
- package/ai-docs/cli-ref/bastion-tunnel.md +30 -0
- package/ai-docs/cli-ref/bucket-sync.md +30 -0
- package/ai-docs/cli-ref/cf-module-update.md +26 -0
- package/ai-docs/cli-ref/cf-rollback.md +28 -0
- package/ai-docs/cli-ref/codebuild-deploy.md +34 -0
- package/ai-docs/cli-ref/compile-template.md +25 -0
- package/ai-docs/cli-ref/container-session.md +30 -0
- package/ai-docs/cli-ref/debug-alarms.md +28 -0
- package/ai-docs/cli-ref/debug-aws-sdk.md +33 -0
- package/ai-docs/cli-ref/debug-container-exec.md +36 -0
- package/ai-docs/cli-ref/debug-dynamodb.md +35 -0
- package/ai-docs/cli-ref/debug-logs.md +34 -0
- package/ai-docs/cli-ref/debug-metrics.md +33 -0
- package/ai-docs/cli-ref/debug-opensearch.md +35 -0
- package/ai-docs/cli-ref/debug-redis.md +36 -0
- package/ai-docs/cli-ref/debug-sql.md +35 -0
- package/ai-docs/cli-ref/defaults-configure.md +29 -0
- package/ai-docs/cli-ref/defaults-list.md +20 -0
- package/ai-docs/cli-ref/delete.md +24 -0
- package/ai-docs/cli-ref/deploy.md +25 -0
- package/ai-docs/cli-ref/deployment-script-run.md +28 -0
- package/ai-docs/cli-ref/dev-stop.md +26 -0
- package/ai-docs/cli-ref/dev.md +45 -0
- package/ai-docs/cli-ref/domain-add.md +26 -0
- package/ai-docs/cli-ref/help.md +18 -0
- package/ai-docs/cli-ref/info-operations.md +22 -0
- package/ai-docs/cli-ref/info-stack.md +30 -0
- package/ai-docs/cli-ref/info-stacks.md +26 -0
- package/ai-docs/cli-ref/info-whoami.md +22 -0
- package/ai-docs/cli-ref/init.md +30 -0
- package/ai-docs/cli-ref/login.md +20 -0
- package/ai-docs/cli-ref/logout.md +18 -0
- package/ai-docs/cli-ref/mcp-add.md +22 -0
- package/ai-docs/cli-ref/mcp.md +20 -0
- package/ai-docs/cli-ref/org-create.md +24 -0
- package/ai-docs/cli-ref/org-delete.md +24 -0
- package/ai-docs/cli-ref/org-list.md +22 -0
- package/ai-docs/cli-ref/package-workloads.md +25 -0
- package/ai-docs/cli-ref/param-get.md +26 -0
- package/ai-docs/cli-ref/preview-changes.md +23 -0
- package/ai-docs/cli-ref/project-create.md +22 -0
- package/ai-docs/cli-ref/projects-list.md +22 -0
- package/ai-docs/cli-ref/rollback.md +28 -0
- package/ai-docs/cli-ref/script-run.md +29 -0
- package/ai-docs/cli-ref/secret-create.md +28 -0
- package/ai-docs/cli-ref/secret-delete.md +26 -0
- package/ai-docs/cli-ref/secret-get.md +26 -0
- package/ai-docs/cli-ref/upgrade.md +20 -0
- package/ai-docs/cli-ref/version.md +18 -0
- package/ai-docs/concept/connecting-resources.md +369 -0
- package/ai-docs/concept/directives.md +371 -0
- package/ai-docs/concept/extending-cloudformation.md +315 -0
- package/ai-docs/concept/overrides-and-transforms.md +352 -0
- package/ai-docs/concept/stages-and-environments.md +347 -0
- package/ai-docs/concept/typescript-config.md +447 -0
- package/ai-docs/concept/yaml-config.md +338 -0
- package/ai-docs/config-ref/_root.md +142 -0
- package/ai-docs/config-ref/application-load-balancer.md +1109 -0
- package/ai-docs/config-ref/astro-web.md +115 -0
- package/ai-docs/config-ref/aws-cdk-construct.md +68 -0
- package/ai-docs/config-ref/bastion.md +93 -0
- package/ai-docs/config-ref/batch-job.md +179 -0
- package/ai-docs/config-ref/bucket.md +348 -0
- package/ai-docs/config-ref/cdn.md +496 -0
- package/ai-docs/config-ref/custom-resource.md +80 -0
- package/ai-docs/config-ref/deployment-script.md +79 -0
- package/ai-docs/config-ref/dynamo-db-table.md +202 -0
- package/ai-docs/config-ref/edge-lambda-function.md +87 -0
- package/ai-docs/config-ref/efs-filesystem.md +72 -0
- package/ai-docs/config-ref/event-bus.md +63 -0
- package/ai-docs/config-ref/function.md +409 -0
- package/ai-docs/config-ref/hosting-bucket.md +171 -0
- package/ai-docs/config-ref/http-api-gateway.md +149 -0
- package/ai-docs/config-ref/http-endpoint.md +92 -0
- package/ai-docs/config-ref/kinesis-stream.md +97 -0
- package/ai-docs/config-ref/mongo-db-atlas-cluster.md +254 -0
- package/ai-docs/config-ref/multi-container-workload.md +399 -0
- package/ai-docs/config-ref/network-load-balancer.md +118 -0
- package/ai-docs/config-ref/nextjs-web.md +147 -0
- package/ai-docs/config-ref/nuxt-web.md +81 -0
- package/ai-docs/config-ref/open-search.md +206 -0
- package/ai-docs/config-ref/private-service.md +75 -0
- package/ai-docs/config-ref/redis-cluster.md +223 -0
- package/ai-docs/config-ref/relational-database.md +525 -0
- package/ai-docs/config-ref/remix-web.md +74 -0
- package/ai-docs/config-ref/sns-topic.md +69 -0
- package/ai-docs/config-ref/solidstart-web.md +75 -0
- package/ai-docs/config-ref/sqs-queue-not-empty.md +405 -0
- package/ai-docs/config-ref/sqs-queue.md +232 -0
- package/ai-docs/config-ref/state-machine.md +235 -0
- package/ai-docs/config-ref/sveltekit-web.md +81 -0
- package/ai-docs/config-ref/tanstack-web.md +75 -0
- package/ai-docs/config-ref/upstash-redis.md +59 -0
- package/ai-docs/config-ref/user-auth-pool.md +876 -0
- package/ai-docs/config-ref/web-app-firewall.md +212 -0
- package/ai-docs/config-ref/web-service.md +178 -0
- package/ai-docs/config-ref/worker-service.md +41 -0
- package/ai-docs/getting-started/console.md +232 -0
- package/ai-docs/getting-started/deployment.md +434 -0
- package/ai-docs/getting-started/dev-mode.md +118 -0
- package/ai-docs/getting-started/how-it-works.md +119 -0
- package/ai-docs/getting-started/intro.md +157 -0
- package/ai-docs/getting-started/using-with-ai.md +228 -0
- package/ai-docs/getting-started/workflow.md +197 -0
- package/ai-docs/index.json +1514 -0
- package/ai-docs/recipe/background-jobs.md +183 -0
- package/ai-docs/recipe/database-migrations.md +240 -0
- package/ai-docs/recipe/graphql-api.md +211 -0
- package/ai-docs/recipe/monorepo-setup.md +183 -0
- package/ai-docs/recipe/nextjs-full-stack.md +188 -0
- package/ai-docs/recipe/rest-api-with-database.md +156 -0
- package/ai-docs/recipe/scheduled-tasks.md +186 -0
- package/ai-docs/recipe/static-website.md +241 -0
- package/ai-docs/troubleshooting/cloudformation-stack-states.md +189 -0
- package/bin/stacktape.js +206 -41
- package/package.json +1 -1
- package/plain.d.ts +309 -54
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
docType: cli-ref
|
|
3
|
+
title: "CLI: script:run"
|
|
4
|
+
tags:
|
|
5
|
+
- script:run
|
|
6
|
+
- script
|
|
7
|
+
- run
|
|
8
|
+
source: src/config/cli/commands.ts
|
|
9
|
+
priority: 3
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# `stacktape script:run`
|
|
13
|
+
|
|
14
|
+
Executes a script defined in your configuration.
|
|
15
|
+
|
|
16
|
+
You can pass environment variables to the script using the `--env` option (e.g., `--env MY_VAR=my_value`).
|
|
17
|
+
|
|
18
|
+
To learn more, refer to the [scripts documentation](https://docs.stacktape.com/configuration/scripts/).
|
|
19
|
+
|
|
20
|
+
## Required Arguments
|
|
21
|
+
|
|
22
|
+
- `--scriptName`
|
|
23
|
+
- `--stage`
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
stacktape script:run --scriptName <value> --stage <value>
|
|
29
|
+
```
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
docType: cli-ref
|
|
3
|
+
title: "CLI: secret:create"
|
|
4
|
+
tags:
|
|
5
|
+
- secret:create
|
|
6
|
+
- secret
|
|
7
|
+
- create
|
|
8
|
+
source: src/config/cli/commands.ts
|
|
9
|
+
priority: 3
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# `stacktape secret:create`
|
|
13
|
+
|
|
14
|
+
Creates a secret that is securely stored in AWS Secrets Manager.
|
|
15
|
+
|
|
16
|
+
This secret can then be referenced in your configuration using the `$Secret('secret-name')` directive. This is useful for storing sensitive data like passwords, API keys, or other credentials.
|
|
17
|
+
|
|
18
|
+
In agent mode, use --secretName with either --secretValue or --secretFile. Use --forceUpdate to update existing secrets without prompting.
|
|
19
|
+
|
|
20
|
+
## Required Arguments
|
|
21
|
+
|
|
22
|
+
- `--region`
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
stacktape secret:create --region <value>
|
|
28
|
+
```
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
docType: cli-ref
|
|
3
|
+
title: "CLI: secret:delete"
|
|
4
|
+
tags:
|
|
5
|
+
- secret:delete
|
|
6
|
+
- secret
|
|
7
|
+
- delete
|
|
8
|
+
source: src/config/cli/commands.ts
|
|
9
|
+
priority: 3
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# `stacktape secret:delete`
|
|
13
|
+
|
|
14
|
+
Deletes a specified secret.
|
|
15
|
+
|
|
16
|
+
In agent mode, use --secretName to specify the secret to delete.
|
|
17
|
+
|
|
18
|
+
## Required Arguments
|
|
19
|
+
|
|
20
|
+
- `--region`
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
stacktape secret:delete --region <value>
|
|
26
|
+
```
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
docType: cli-ref
|
|
3
|
+
title: "CLI: secret:get"
|
|
4
|
+
tags:
|
|
5
|
+
- secret:get
|
|
6
|
+
- secret
|
|
7
|
+
- get
|
|
8
|
+
source: src/config/cli/commands.ts
|
|
9
|
+
priority: 3
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# `stacktape secret:get`
|
|
13
|
+
|
|
14
|
+
Prints details about a specified secret to the console.
|
|
15
|
+
|
|
16
|
+
In agent mode, use --secretName to specify the secret.
|
|
17
|
+
|
|
18
|
+
## Required Arguments
|
|
19
|
+
|
|
20
|
+
- `--region`
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
stacktape secret:get --region <value>
|
|
26
|
+
```
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
docType: cli-ref
|
|
3
|
+
title: "CLI: upgrade"
|
|
4
|
+
tags:
|
|
5
|
+
- upgrade
|
|
6
|
+
source: src/config/cli/commands.ts
|
|
7
|
+
priority: 3
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# `stacktape upgrade`
|
|
11
|
+
|
|
12
|
+
Upgrades Stacktape to the latest version.
|
|
13
|
+
|
|
14
|
+
You can also specify a version to install using the `--version` option.
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
stacktape upgrade
|
|
20
|
+
```
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
docType: cli-ref
|
|
3
|
+
title: "CLI: version"
|
|
4
|
+
tags:
|
|
5
|
+
- version
|
|
6
|
+
source: src/config/cli/commands.ts
|
|
7
|
+
priority: 3
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# `stacktape version`
|
|
11
|
+
|
|
12
|
+
Prints the current version of Stacktape.
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
stacktape version
|
|
18
|
+
```
|
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
---
|
|
2
|
+
docType: concept
|
|
3
|
+
title: Connecting Resources
|
|
4
|
+
tags:
|
|
5
|
+
- connecting
|
|
6
|
+
- resources
|
|
7
|
+
- concept
|
|
8
|
+
source: docs/_curated-docs/concepts/connecting-resources.mdx
|
|
9
|
+
priority: 1
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Connecting Resources
|
|
13
|
+
|
|
14
|
+
The `connectTo` property is one of Stacktape's most powerful features. It automatically handles the complex configuration needed to connect resources together.
|
|
15
|
+
|
|
16
|
+
## What connectTo Does
|
|
17
|
+
|
|
18
|
+
When you use `connectTo`, Stacktape automatically:
|
|
19
|
+
|
|
20
|
+
1. **Grants IAM permissions** - The source resource gets permission to access the target
|
|
21
|
+
2. **Injects environment variables** - Connection details are added as `STP_*` variables
|
|
22
|
+
3. **Configures security groups** - Network traffic is allowed between resources
|
|
23
|
+
4. **Handles VPC placement** - Resources are placed in the same VPC when needed
|
|
24
|
+
|
|
25
|
+
## Basic Usage
|
|
26
|
+
|
|
27
|
+
```yaml
|
|
28
|
+
resources:
|
|
29
|
+
database:
|
|
30
|
+
type: relational-database
|
|
31
|
+
properties:
|
|
32
|
+
engine:
|
|
33
|
+
type: postgres
|
|
34
|
+
properties:
|
|
35
|
+
version: '16'
|
|
36
|
+
|
|
37
|
+
handler:
|
|
38
|
+
type: function
|
|
39
|
+
properties:
|
|
40
|
+
packaging:
|
|
41
|
+
type: stacktape-lambda-buildpack
|
|
42
|
+
properties:
|
|
43
|
+
entryfilePath: ./src/handler.ts
|
|
44
|
+
connectTo:
|
|
45
|
+
- database
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
This single line (`connectTo: [database]`) replaces dozens of lines of manual IAM policies, environment variable configuration, and networking setup.
|
|
49
|
+
|
|
50
|
+
## Environment Variables
|
|
51
|
+
|
|
52
|
+
When you connect to a resource, Stacktape injects environment variables with a `STP_` prefix followed by the resource name in uppercase.
|
|
53
|
+
|
|
54
|
+
### Database Variables
|
|
55
|
+
|
|
56
|
+
```yaml
|
|
57
|
+
connectTo:
|
|
58
|
+
- database # Name of the relational-database resource
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Injected variables:
|
|
62
|
+
|
|
63
|
+
- `STP_DATABASE_CONNECTION_STRING` - Full connection string
|
|
64
|
+
- `STP_DATABASE_HOST` - Database hostname
|
|
65
|
+
- `STP_DATABASE_PORT` - Database port
|
|
66
|
+
- `STP_DATABASE_NAME` - Database name
|
|
67
|
+
- `STP_DATABASE_USER` - Master username
|
|
68
|
+
- `STP_DATABASE_PASSWORD` - Master password
|
|
69
|
+
|
|
70
|
+
### S3 Bucket Variables
|
|
71
|
+
|
|
72
|
+
```yaml
|
|
73
|
+
connectTo:
|
|
74
|
+
- uploads # Name of the bucket resource
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Injected variables:
|
|
78
|
+
|
|
79
|
+
- `STP_UPLOADS_BUCKET_NAME` - Bucket name
|
|
80
|
+
- `STP_UPLOADS_BUCKET_ARN` - Bucket ARN
|
|
81
|
+
|
|
82
|
+
### DynamoDB Table Variables
|
|
83
|
+
|
|
84
|
+
```yaml
|
|
85
|
+
connectTo:
|
|
86
|
+
- usersTable # Name of the dynamo-db-table resource
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Injected variables:
|
|
90
|
+
|
|
91
|
+
- `STP_USERS_TABLE_TABLE_NAME` - Table name
|
|
92
|
+
- `STP_USERS_TABLE_TABLE_ARN` - Table ARN
|
|
93
|
+
- `STP_USERS_TABLE_STREAM_ARN` - Stream ARN (if enabled)
|
|
94
|
+
|
|
95
|
+
### SQS Queue Variables
|
|
96
|
+
|
|
97
|
+
```yaml
|
|
98
|
+
connectTo:
|
|
99
|
+
- jobQueue # Name of the sqs-queue resource
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Injected variables:
|
|
103
|
+
|
|
104
|
+
- `STP_JOB_QUEUE_QUEUE_URL` - Queue URL
|
|
105
|
+
- `STP_JOB_QUEUE_QUEUE_ARN` - Queue ARN
|
|
106
|
+
|
|
107
|
+
### SNS Topic Variables
|
|
108
|
+
|
|
109
|
+
```yaml
|
|
110
|
+
connectTo:
|
|
111
|
+
- notifications # Name of the sns-topic resource
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Injected variables:
|
|
115
|
+
|
|
116
|
+
- `STP_NOTIFICATIONS_TOPIC_ARN` - Topic ARN
|
|
117
|
+
|
|
118
|
+
### Redis Variables
|
|
119
|
+
|
|
120
|
+
```yaml
|
|
121
|
+
connectTo:
|
|
122
|
+
- cache # Name of the redis-cluster resource
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Injected variables:
|
|
126
|
+
|
|
127
|
+
- `STP_CACHE_HOST` - Redis host
|
|
128
|
+
- `STP_CACHE_PORT` - Redis port
|
|
129
|
+
- `STP_CACHE_PRIMARY_HOST` - Primary node host
|
|
130
|
+
- `STP_CACHE_READER_HOST` - Reader endpoint (if replicas exist)
|
|
131
|
+
|
|
132
|
+
### Event Bus Variables
|
|
133
|
+
|
|
134
|
+
```yaml
|
|
135
|
+
connectTo:
|
|
136
|
+
- events # Name of the event-bus resource
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Injected variables:
|
|
140
|
+
|
|
141
|
+
- `STP_EVENTS_EVENT_BUS_NAME` - Event bus name
|
|
142
|
+
- `STP_EVENTS_EVENT_BUS_ARN` - Event bus ARN
|
|
143
|
+
|
|
144
|
+
## Using in Your Code
|
|
145
|
+
|
|
146
|
+
Access the injected environment variables in your application:
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
// src/handler.ts
|
|
150
|
+
import { Client } from 'pg';
|
|
151
|
+
|
|
152
|
+
export const handler = async () => {
|
|
153
|
+
// Connection string is automatically available
|
|
154
|
+
const client = new Client({
|
|
155
|
+
connectionString: process.env.STP_DATABASE_CONNECTION_STRING
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
await client.connect();
|
|
159
|
+
const result = await client.query('SELECT NOW()');
|
|
160
|
+
await client.end();
|
|
161
|
+
|
|
162
|
+
return { statusCode: 200, body: JSON.stringify(result.rows) };
|
|
163
|
+
};
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Or with individual variables:
|
|
167
|
+
|
|
168
|
+
```typescript
|
|
169
|
+
import { Client } from 'pg';
|
|
170
|
+
|
|
171
|
+
const client = new Client({
|
|
172
|
+
host: process.env.STP_DATABASE_HOST,
|
|
173
|
+
port: parseInt(process.env.STP_DATABASE_PORT || '5432'),
|
|
174
|
+
database: process.env.STP_DATABASE_NAME,
|
|
175
|
+
user: process.env.STP_DATABASE_USER,
|
|
176
|
+
password: process.env.STP_DATABASE_PASSWORD
|
|
177
|
+
});
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Multiple Connections
|
|
181
|
+
|
|
182
|
+
Connect to multiple resources at once:
|
|
183
|
+
|
|
184
|
+
```yaml
|
|
185
|
+
resources:
|
|
186
|
+
database:
|
|
187
|
+
type: relational-database
|
|
188
|
+
properties:
|
|
189
|
+
engine:
|
|
190
|
+
type: postgres
|
|
191
|
+
|
|
192
|
+
uploads:
|
|
193
|
+
type: bucket
|
|
194
|
+
|
|
195
|
+
cache:
|
|
196
|
+
type: redis-cluster
|
|
197
|
+
properties:
|
|
198
|
+
instanceSize: cache.t4g.micro
|
|
199
|
+
defaultUserPassword: $Secret('redis-password')
|
|
200
|
+
|
|
201
|
+
handler:
|
|
202
|
+
type: function
|
|
203
|
+
properties:
|
|
204
|
+
packaging:
|
|
205
|
+
type: stacktape-lambda-buildpack
|
|
206
|
+
properties:
|
|
207
|
+
entryfilePath: ./src/handler.ts
|
|
208
|
+
connectTo:
|
|
209
|
+
- database
|
|
210
|
+
- uploads
|
|
211
|
+
- cache
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Your handler now has access to:
|
|
215
|
+
|
|
216
|
+
- `STP_DATABASE_*` variables
|
|
217
|
+
- `STP_UPLOADS_*` variables
|
|
218
|
+
- `STP_CACHE_*` variables
|
|
219
|
+
|
|
220
|
+
## IAM Permissions Granted
|
|
221
|
+
|
|
222
|
+
`connectTo` grants appropriate permissions based on the resource type:
|
|
223
|
+
|
|
224
|
+
| Target Resource | Permissions Granted |
|
|
225
|
+
| --------------------- | ----------------------------------------------------------------------------------------------------------------------- |
|
|
226
|
+
| `relational-database` | Network access (security group) |
|
|
227
|
+
| `bucket` | `s3:GetObject`, `s3:PutObject`, `s3:DeleteObject`, `s3:ListBucket` |
|
|
228
|
+
| `dynamo-db-table` | `dynamodb:GetItem`, `dynamodb:PutItem`, `dynamodb:UpdateItem`, `dynamodb:DeleteItem`, `dynamodb:Query`, `dynamodb:Scan` |
|
|
229
|
+
| `sqs-queue` | `sqs:SendMessage`, `sqs:ReceiveMessage`, `sqs:DeleteMessage` |
|
|
230
|
+
| `sns-topic` | `sns:Publish` |
|
|
231
|
+
| `event-bus` | `events:PutEvents` |
|
|
232
|
+
| `redis-cluster` | Network access (security group) |
|
|
233
|
+
| `user-auth-pool` | `cognito-idp:*` |
|
|
234
|
+
|
|
235
|
+
## Custom Permissions
|
|
236
|
+
|
|
237
|
+
If you need more fine-grained control, use `iamRoleStatements` instead of or in addition to `connectTo`:
|
|
238
|
+
|
|
239
|
+
```yaml
|
|
240
|
+
resources:
|
|
241
|
+
uploads:
|
|
242
|
+
type: bucket
|
|
243
|
+
|
|
244
|
+
handler:
|
|
245
|
+
type: function
|
|
246
|
+
properties:
|
|
247
|
+
packaging:
|
|
248
|
+
type: stacktape-lambda-buildpack
|
|
249
|
+
properties:
|
|
250
|
+
entryfilePath: ./src/handler.ts
|
|
251
|
+
# connectTo for env vars and basic permissions
|
|
252
|
+
connectTo:
|
|
253
|
+
- uploads
|
|
254
|
+
# Additional custom permissions
|
|
255
|
+
iamRoleStatements:
|
|
256
|
+
- Effect: Allow
|
|
257
|
+
Action:
|
|
258
|
+
- s3:GetObjectVersion
|
|
259
|
+
- s3:GetObjectTagging
|
|
260
|
+
Resource:
|
|
261
|
+
- $ResourceParam('uploads', 'bucketArn')/*
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
## Scripts with connectTo
|
|
265
|
+
|
|
266
|
+
Scripts also support `connectTo`:
|
|
267
|
+
|
|
268
|
+
```yaml
|
|
269
|
+
resources:
|
|
270
|
+
database:
|
|
271
|
+
type: relational-database
|
|
272
|
+
properties:
|
|
273
|
+
engine:
|
|
274
|
+
type: postgres
|
|
275
|
+
|
|
276
|
+
scripts:
|
|
277
|
+
migrate:
|
|
278
|
+
type: local-script
|
|
279
|
+
properties:
|
|
280
|
+
executeCommand: npx prisma migrate deploy
|
|
281
|
+
connectTo:
|
|
282
|
+
- database
|
|
283
|
+
environment:
|
|
284
|
+
- name: DATABASE_URL
|
|
285
|
+
value: $ResourceParam('database', 'connectionString')
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
When you run the script, the database connection details are available:
|
|
289
|
+
|
|
290
|
+
```bash
|
|
291
|
+
stacktape script:run --scriptName migrate --stage dev --region us-east-1
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
## Connecting Container Services
|
|
295
|
+
|
|
296
|
+
Container services (web-service, private-service, worker-service) work the same way:
|
|
297
|
+
|
|
298
|
+
```yaml
|
|
299
|
+
resources:
|
|
300
|
+
database:
|
|
301
|
+
type: relational-database
|
|
302
|
+
properties:
|
|
303
|
+
engine:
|
|
304
|
+
type: postgres
|
|
305
|
+
|
|
306
|
+
api:
|
|
307
|
+
type: web-service
|
|
308
|
+
properties:
|
|
309
|
+
packaging:
|
|
310
|
+
type: stacktape-image-buildpack
|
|
311
|
+
properties:
|
|
312
|
+
entryfilePath: ./src/server.ts
|
|
313
|
+
resources:
|
|
314
|
+
cpu: 0.5
|
|
315
|
+
memory: 1024
|
|
316
|
+
connectTo:
|
|
317
|
+
- database
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
## VPC Considerations
|
|
321
|
+
|
|
322
|
+
When connecting to VPC-only resources (like databases with `accessibilityMode: vpc`):
|
|
323
|
+
|
|
324
|
+
1. **Lambda functions** are automatically placed in the VPC
|
|
325
|
+
2. **Container services** are automatically placed in the VPC
|
|
326
|
+
3. **Security groups** are configured to allow traffic
|
|
327
|
+
|
|
328
|
+
## Without connectTo
|
|
329
|
+
|
|
330
|
+
For comparison, here's what you'd need without `connectTo`:
|
|
331
|
+
|
|
332
|
+
```yaml
|
|
333
|
+
# WITHOUT connectTo - Manual configuration
|
|
334
|
+
resources:
|
|
335
|
+
database:
|
|
336
|
+
type: relational-database
|
|
337
|
+
properties:
|
|
338
|
+
engine:
|
|
339
|
+
type: postgres
|
|
340
|
+
|
|
341
|
+
handler:
|
|
342
|
+
type: function
|
|
343
|
+
properties:
|
|
344
|
+
packaging:
|
|
345
|
+
type: stacktape-lambda-buildpack
|
|
346
|
+
properties:
|
|
347
|
+
entryfilePath: ./src/handler.ts
|
|
348
|
+
# Manual environment variables
|
|
349
|
+
environment:
|
|
350
|
+
- name: DB_HOST
|
|
351
|
+
value: $ResourceParam('database', 'host')
|
|
352
|
+
- name: DB_PORT
|
|
353
|
+
value: $ResourceParam('database', 'port')
|
|
354
|
+
- name: DB_NAME
|
|
355
|
+
value: $ResourceParam('database', 'name')
|
|
356
|
+
- name: DB_USER
|
|
357
|
+
value: $ResourceParam('database', 'masterUserName')
|
|
358
|
+
- name: DB_PASSWORD
|
|
359
|
+
value: $ResourceParam('database', 'masterUserPassword')
|
|
360
|
+
# Manual VPC configuration
|
|
361
|
+
vpc:
|
|
362
|
+
useDefaultVpc: true
|
|
363
|
+
securityGroupIds:
|
|
364
|
+
- $ResourceParam('database', 'securityGroupId')
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
With `connectTo`, all of this is handled automatically.
|
|
368
|
+
|
|
369
|
+
## Next Steps
|