0
# Database Services
1
2
Comprehensive database solutions including relational databases (RDS), NoSQL databases (DynamoDB), caching systems (ElastiCache), and data warehousing solutions.
3
4
## Capabilities
5
6
### RDS - Relational Database Service
7
8
Managed relational database service supporting MySQL, PostgreSQL, MariaDB, Oracle, and SQL Server.
9
10
```typescript { .api }
11
/**
12
* RDS database instance
13
*/
14
class rds.Instance extends pulumi.CustomResource {
15
constructor(name: string, args: rds.InstanceArgs, opts?: pulumi.CustomResourceOptions);
16
17
/** Database instance ARN */
18
readonly arn: pulumi.Output<string>;
19
/** Database instance identifier */
20
readonly identifier: pulumi.Output<string>;
21
/** Database engine */
22
readonly engine: pulumi.Output<string>;
23
/** Engine version */
24
readonly engineVersion: pulumi.Output<string>;
25
/** Instance class */
26
readonly instanceClass: pulumi.Output<string>;
27
/** Database name */
28
readonly dbName: pulumi.Output<string>;
29
/** Allocated storage in GB */
30
readonly allocatedStorage: pulumi.Output<number>;
31
/** Storage type */
32
readonly storageType: pulumi.Output<string>;
33
/** Storage encrypted */
34
readonly storageEncrypted: pulumi.Output<boolean>;
35
/** Database endpoint */
36
readonly endpoint: pulumi.Output<string>;
37
/** Database port */
38
readonly port: pulumi.Output<number>;
39
/** Master username */
40
readonly username: pulumi.Output<string>;
41
/** VPC security group IDs */
42
readonly vpcSecurityGroupIds: pulumi.Output<string[]>;
43
/** DB subnet group name */
44
readonly dbSubnetGroupName: pulumi.Output<string>;
45
/** Parameter group name */
46
readonly parameterGroupName: pulumi.Output<string>;
47
/** Multi-AZ deployment */
48
readonly multiAz: pulumi.Output<boolean>;
49
/** Availability zone */
50
readonly availabilityZone: pulumi.Output<string>;
51
/** Backup retention period */
52
readonly backupRetentionPeriod: pulumi.Output<number>;
53
/** Resource tags */
54
readonly tags: pulumi.Output<{[key: string]: string}>;
55
}
56
57
interface rds.InstanceArgs {
58
/** Database instance identifier */
59
identifier?: pulumi.Input<string>;
60
/** Database engine (mysql, postgres, mariadb, oracle-ee, sqlserver-ex) */
61
engine: pulumi.Input<string>;
62
/** Engine version */
63
engineVersion?: pulumi.Input<string>;
64
/** Instance class (db.t3.micro, db.r5.large, etc.) */
65
instanceClass: pulumi.Input<string>;
66
/** Initial database name */
67
dbName?: pulumi.Input<string>;
68
/** Master username */
69
username: pulumi.Input<string>;
70
/** Master password */
71
password?: pulumi.Input<string>;
72
/** Manage master user password */
73
manageMasterUserPassword?: pulumi.Input<boolean>;
74
/** Allocated storage in GB */
75
allocatedStorage?: pulumi.Input<number>;
76
/** Maximum allocated storage (auto-scaling) */
77
maxAllocatedStorage?: pulumi.Input<number>;
78
/** Storage type (gp2, gp3, io1, standard) */
79
storageType?: pulumi.Input<string>;
80
/** Storage IOPS */
81
iops?: pulumi.Input<number>;
82
/** Enable storage encryption */
83
storageEncrypted?: pulumi.Input<boolean>;
84
/** KMS key ID for encryption */
85
kmsKeyId?: pulumi.Input<string>;
86
/** VPC security group IDs */
87
vpcSecurityGroupIds?: pulumi.Input<pulumi.Input<string>[]>;
88
/** DB subnet group name */
89
dbSubnetGroupName?: pulumi.Input<string>;
90
/** Parameter group name */
91
parameterGroupName?: pulumi.Input<string>;
92
/** Enable multi-AZ deployment */
93
multiAz?: pulumi.Input<boolean>;
94
/** Availability zone */
95
availabilityZone?: pulumi.Input<string>;
96
/** Backup retention period (0-35 days) */
97
backupRetentionPeriod?: pulumi.Input<number>;
98
/** Backup window */
99
backupWindow?: pulumi.Input<string>;
100
/** Maintenance window */
101
maintenanceWindow?: pulumi.Input<string>;
102
/** Enable auto minor version upgrade */
103
autoMinorVersionUpgrade?: pulumi.Input<boolean>;
104
/** Enable deletion protection */
105
deletionProtection?: pulumi.Input<boolean>;
106
/** Skip final snapshot */
107
skipFinalSnapshot?: pulumi.Input<boolean>;
108
/** Final snapshot identifier */
109
finalSnapshotIdentifier?: pulumi.Input<string>;
110
/** Resource tags */
111
tags?: pulumi.Input<{[key: string]: pulumi.Input<string>}>;
112
}
113
114
/**
115
* RDS subnet group for VPC deployment
116
*/
117
class rds.SubnetGroup extends pulumi.CustomResource {
118
constructor(name: string, args: rds.SubnetGroupArgs, opts?: pulumi.CustomResourceOptions);
119
120
/** Subnet group name */
121
readonly name: pulumi.Output<string>;
122
/** Description */
123
readonly description: pulumi.Output<string>;
124
/** Subnet IDs */
125
readonly subnetIds: pulumi.Output<string[]>;
126
/** Resource tags */
127
readonly tags: pulumi.Output<{[key: string]: string}>;
128
}
129
130
/**
131
* RDS parameter group for configuration
132
*/
133
class rds.ParameterGroup extends pulumi.CustomResource {
134
constructor(name: string, args: rds.ParameterGroupArgs, opts?: pulumi.CustomResourceOptions);
135
136
/** Parameter group name */
137
readonly name: pulumi.Output<string>;
138
/** Database family */
139
readonly family: pulumi.Output<string>;
140
/** Description */
141
readonly description: pulumi.Output<string>;
142
/** Parameters */
143
readonly parameters: pulumi.Output<rds.ParameterGroupParameter[]>;
144
}
145
```
146
147
**Usage Examples:**
148
149
```typescript
150
// Create RDS subnet group
151
const dbSubnetGroup = new aws.rds.SubnetGroup("db-subnet-group", {
152
name: "main-db-subnet-group",
153
subnetIds: privateSubnets.map(s => s.id),
154
description: "Subnet group for RDS instances",
155
tags: {
156
Name: "MainDBSubnetGroup"
157
}
158
});
159
160
// Create parameter group for PostgreSQL
161
const dbParameterGroup = new aws.rds.ParameterGroup("db-params", {
162
family: "postgres14",
163
description: "Custom parameter group for PostgreSQL 14",
164
parameters: [
165
{
166
name: "shared_preload_libraries",
167
value: "pg_stat_statements"
168
},
169
{
170
name: "log_statement",
171
value: "all"
172
}
173
]
174
});
175
176
// Create RDS instance
177
const database = new aws.rds.Instance("main-db", {
178
identifier: "main-database",
179
engine: "postgres",
180
engineVersion: "14.9",
181
instanceClass: "db.r5.large",
182
allocatedStorage: 100,
183
maxAllocatedStorage: 1000,
184
storageType: "gp3",
185
storageEncrypted: true,
186
dbName: "mainapp",
187
username: "dbadmin",
188
manageMasterUserPassword: true,
189
dbSubnetGroupName: dbSubnetGroup.name,
190
parameterGroupName: dbParameterGroup.name,
191
vpcSecurityGroupIds: [dbSecurityGroup.id],
192
backupRetentionPeriod: 7,
193
backupWindow: "03:00-04:00",
194
maintenanceWindow: "sun:04:00-sun:05:00",
195
multiAz: true,
196
deletionProtection: true,
197
skipFinalSnapshot: false,
198
finalSnapshotIdentifier: "main-db-final-snapshot",
199
tags: {
200
Name: "MainDatabase",
201
Environment: "production"
202
}
203
});
204
```
205
206
### DynamoDB - NoSQL Database
207
208
Fully managed NoSQL database service with single-digit millisecond latency at any scale.
209
210
```typescript { .api }
211
/**
212
* DynamoDB table
213
*/
214
class dynamodb.Table extends pulumi.CustomResource {
215
constructor(name: string, args: dynamodb.TableArgs, opts?: pulumi.CustomResourceOptions);
216
217
/** Table ARN */
218
readonly arn: pulumi.Output<string>;
219
/** Table name */
220
readonly name: pulumi.Output<string>;
221
/** Hash key (partition key) */
222
readonly hashKey: pulumi.Output<string>;
223
/** Range key (sort key) */
224
readonly rangeKey: pulumi.Output<string>;
225
/** Billing mode */
226
readonly billingMode: pulumi.Output<string>;
227
/** Read capacity units */
228
readonly readCapacity: pulumi.Output<number>;
229
/** Write capacity units */
230
readonly writeCapacity: pulumi.Output<number>;
231
/** Attribute definitions */
232
readonly attributes: pulumi.Output<dynamodb.TableAttribute[]>;
233
/** Global secondary indexes */
234
readonly globalSecondaryIndexes: pulumi.Output<dynamodb.TableGlobalSecondaryIndex[]>;
235
/** Local secondary indexes */
236
readonly localSecondaryIndexes: pulumi.Output<dynamodb.TableLocalSecondaryIndex[]>;
237
/** Server-side encryption */
238
readonly serverSideEncryption: pulumi.Output<dynamodb.TableServerSideEncryption>;
239
/** Stream specification */
240
readonly streamSpecification: pulumi.Output<dynamodb.TableStreamSpecification>;
241
/** Time to live */
242
readonly ttl: pulumi.Output<dynamodb.TableTtl>;
243
/** Point-in-time recovery */
244
readonly pointInTimeRecovery: pulumi.Output<dynamodb.TablePointInTimeRecovery>;
245
/** Resource tags */
246
readonly tags: pulumi.Output<{[key: string]: string}>;
247
}
248
249
interface dynamodb.TableArgs {
250
/** Table name */
251
name?: pulumi.Input<string>;
252
/** Hash key attribute name */
253
hashKey: pulumi.Input<string>;
254
/** Range key attribute name */
255
rangeKey?: pulumi.Input<string>;
256
/** Billing mode (PROVISIONED or PAY_PER_REQUEST) */
257
billingMode?: pulumi.Input<string>;
258
/** Read capacity units (for PROVISIONED) */
259
readCapacity?: pulumi.Input<number>;
260
/** Write capacity units (for PROVISIONED) */
261
writeCapacity?: pulumi.Input<number>;
262
/** Attribute definitions */
263
attributes: pulumi.Input<pulumi.Input<dynamodb.TableAttribute>[]>;
264
/** Global secondary indexes */
265
globalSecondaryIndexes?: pulumi.Input<pulumi.Input<dynamodb.TableGlobalSecondaryIndex>[]>;
266
/** Local secondary indexes */
267
localSecondaryIndexes?: pulumi.Input<pulumi.Input<dynamodb.TableLocalSecondaryIndex>[]>;
268
/** Server-side encryption */
269
serverSideEncryption?: pulumi.Input<dynamodb.TableServerSideEncryption>;
270
/** DynamoDB Streams */
271
streamSpecification?: pulumi.Input<dynamodb.TableStreamSpecification>;
272
/** Time to live configuration */
273
ttl?: pulumi.Input<dynamodb.TableTtl>;
274
/** Point-in-time recovery */
275
pointInTimeRecovery?: pulumi.Input<dynamodb.TablePointInTimeRecovery>;
276
/** Resource tags */
277
tags?: pulumi.Input<{[key: string]: pulumi.Input<string>}>;
278
}
279
280
interface dynamodb.TableAttribute {
281
/** Attribute name */
282
name: pulumi.Input<string>;
283
/** Attribute type (S, N, B) */
284
type: pulumi.Input<string>;
285
}
286
287
interface dynamodb.TableGlobalSecondaryIndex {
288
/** Index name */
289
name: pulumi.Input<string>;
290
/** Hash key */
291
hashKey: pulumi.Input<string>;
292
/** Range key */
293
rangeKey?: pulumi.Input<string>;
294
/** Projection type */
295
projectionType: pulumi.Input<string>;
296
/** Non-key attributes to project */
297
nonKeyAttributes?: pulumi.Input<pulumi.Input<string>[]>;
298
/** Read capacity units */
299
readCapacity?: pulumi.Input<number>;
300
/** Write capacity units */
301
writeCapacity?: pulumi.Input<number>;
302
}
303
```
304
305
**Usage Examples:**
306
307
```typescript
308
// Create DynamoDB table with GSI
309
const userTable = new aws.dynamodb.Table("users", {
310
name: "users",
311
billingMode: "PAY_PER_REQUEST",
312
hashKey: "userId",
313
attributes: [
314
{ name: "userId", type: "S" },
315
{ name: "email", type: "S" },
316
{ name: "createdAt", type: "N" }
317
],
318
globalSecondaryIndexes: [{
319
name: "email-index",
320
hashKey: "email",
321
projectionType: "ALL"
322
}, {
323
name: "created-index",
324
hashKey: "createdAt",
325
projectionType: "KEYS_ONLY"
326
}],
327
serverSideEncryption: {
328
enabled: true
329
},
330
pointInTimeRecovery: {
331
enabled: true
332
},
333
ttl: {
334
attributeName: "expires",
335
enabled: true
336
},
337
tags: {
338
Name: "UserTable",
339
Environment: "production"
340
}
341
});
342
343
// Provisioned capacity table
344
const sessionTable = new aws.dynamodb.Table("sessions", {
345
name: "user-sessions",
346
billingMode: "PROVISIONED",
347
hashKey: "sessionId",
348
readCapacity: 10,
349
writeCapacity: 10,
350
attributes: [
351
{ name: "sessionId", type: "S" }
352
],
353
streamSpecification: {
354
streamEnabled: true,
355
streamViewType: "NEW_AND_OLD_IMAGES"
356
}
357
});
358
```
359
360
### ElastiCache - In-Memory Caching
361
362
Fully managed in-memory caching service supporting Redis and Memcached.
363
364
```typescript { .api }
365
/**
366
* ElastiCache Redis cluster
367
*/
368
class elasticache.ReplicationGroup extends pulumi.CustomResource {
369
constructor(name: string, args: elasticache.ReplicationGroupArgs, opts?: pulumi.CustomResourceOptions);
370
371
/** Replication group ID */
372
readonly replicationGroupId: pulumi.Output<string>;
373
/** Description */
374
readonly description: pulumi.Output<string>;
375
/** Node type */
376
readonly nodeType: pulumi.Output<string>;
377
/** Port */
378
readonly port: pulumi.Output<number>;
379
/** Parameter group name */
380
readonly parameterGroupName: pulumi.Output<string>;
381
/** Subnet group name */
382
readonly subnetGroupName: pulumi.Output<string>;
383
/** Security group IDs */
384
readonly securityGroupIds: pulumi.Output<string[]>;
385
/** Number of cache clusters */
386
readonly numCacheClusters: pulumi.Output<number>;
387
/** Automatic failover enabled */
388
readonly automaticFailoverEnabled: pulumi.Output<boolean>;
389
/** Multi-AZ enabled */
390
readonly multiAzEnabled: pulumi.Output<boolean>;
391
/** Engine version */
392
readonly engineVersion: pulumi.Output<string>;
393
/** At-rest encryption enabled */
394
readonly atRestEncryptionEnabled: pulumi.Output<boolean>;
395
/** Transit encryption enabled */
396
readonly transitEncryptionEnabled: pulumi.Output<boolean>;
397
/** Auth token */
398
readonly authToken: pulumi.Output<string>;
399
/** Configuration endpoint */
400
readonly configurationEndpoint: pulumi.Output<elasticache.ReplicationGroupConfigurationEndpoint>;
401
/** Primary endpoint */
402
readonly primaryEndpoint: pulumi.Output<string>;
403
/** Reader endpoint */
404
readonly readerEndpoint: pulumi.Output<string>;
405
}
406
407
/**
408
* ElastiCache subnet group
409
*/
410
class elasticache.SubnetGroup extends pulumi.CustomResource {
411
constructor(name: string, args: elasticache.SubnetGroupArgs, opts?: pulumi.CustomResourceOptions);
412
413
/** Subnet group name */
414
readonly name: pulumi.Output<string>;
415
/** Description */
416
readonly description: pulumi.Output<string>;
417
/** Subnet IDs */
418
readonly subnetIds: pulumi.Output<string[]>;
419
}
420
421
/**
422
* ElastiCache parameter group
423
*/
424
class elasticache.ParameterGroup extends pulumi.CustomResource {
425
constructor(name: string, args: elasticache.ParameterGroupArgs, opts?: pulumi.CustomResourceOptions);
426
427
/** Parameter group name */
428
readonly name: pulumi.Output<string>;
429
/** Family */
430
readonly family: pulumi.Output<string>;
431
/** Description */
432
readonly description: pulumi.Output<string>;
433
/** Parameters */
434
readonly parameters: pulumi.Output<elasticache.ParameterGroupParameter[]>;
435
}
436
```
437
438
**Usage Examples:**
439
440
```typescript
441
// Create ElastiCache subnet group
442
const cacheSubnetGroup = new aws.elasticache.SubnetGroup("cache-subnet", {
443
name: "cache-subnet-group",
444
subnetIds: privateSubnets.map(s => s.id),
445
description: "Subnet group for ElastiCache"
446
});
447
448
// Create Redis parameter group
449
const redisParams = new aws.elasticache.ParameterGroup("redis-params", {
450
family: "redis7.x",
451
description: "Custom Redis parameters",
452
parameters: [
453
{
454
name: "maxmemory-policy",
455
value: "allkeys-lru"
456
}
457
]
458
});
459
460
// Create Redis replication group
461
const redisCluster = new aws.elasticache.ReplicationGroup("redis", {
462
replicationGroupId: "app-redis",
463
description: "Redis cluster for application caching",
464
nodeType: "cache.r6g.large",
465
port: 6379,
466
parameterGroupName: redisParams.name,
467
subnetGroupName: cacheSubnetGroup.name,
468
securityGroupIds: [cacheSecurityGroup.id],
469
numCacheClusters: 3,
470
automaticFailoverEnabled: true,
471
multiAzEnabled: true,
472
engineVersion: "7.0",
473
atRestEncryptionEnabled: true,
474
transitEncryptionEnabled: true,
475
authToken: "my-secure-auth-token",
476
tags: {
477
Name: "AppRedisCluster",
478
Environment: "production"
479
}
480
});
481
```