Skip to content

Commit 0eaa118

Browse files
committed
Parametrize docker image and persistent storage volume path for mongo service
1 parent 8a69da5 commit 0eaa118

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/components/mongo.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export type MongoArgs = Pick<
66
EcsServiceArgs,
77
'size' | 'clusterId' | 'clusterName' | 'vpcId' | 'vpcCidrBlock' | 'tags'
88
> & {
9+
privateSubnetIds: pulumi.Input<pulumi.Input<string>[]>;
910
/**
1011
* Username for the master DB user.
1112
*/
@@ -15,11 +16,18 @@ export type MongoArgs = Pick<
1516
* The value will be stored as a secret in AWS Secret Manager.
1617
*/
1718
password?: pulumi.Input<string>;
18-
privateSubnetIds: pulumi.Input<pulumi.Input<string>[]>;
19+
/**
20+
* Mongo Docker image. Defaults to mongo:7.0.3.
21+
*/
22+
image?: pulumi.Input<string>;
1923
/**
2024
* Exposed service port. Defaults to 27017.
2125
*/
2226
port?: pulumi.Input<number>;
27+
/**
28+
* Persistent storage volume path. Defaults to '/data/db'.
29+
*/
30+
persistentStorageVolumePath?: pulumi.Input<string>;
2331
};
2432

2533
export class Mongo extends pulumi.ComponentResource {
@@ -34,7 +42,12 @@ export class Mongo extends pulumi.ComponentResource {
3442
) {
3543
super('studion:Mongo', name, args, opts);
3644

45+
const image =
46+
args.image ||
47+
'mongo:7.0.3@sha256:238b1636bdd7820c752b91bec8a669f92568eb313ad89a1fc4a92903c1b40489';
3748
const port = args.port || 27017;
49+
const persistentStorageVolumePath =
50+
args.persistentStorageVolumePath || '/data/db';
3851

3952
const { username, password, privateSubnetIds, ...ecsServiceArgs } = args;
4053

@@ -51,12 +64,11 @@ export class Mongo extends pulumi.ComponentResource {
5164
{
5265
...ecsServiceArgs,
5366
port,
54-
image:
55-
'mongo:7.0.3@sha256:238b1636bdd7820c752b91bec8a669f92568eb313ad89a1fc4a92903c1b40489',
67+
image,
5668
desiredCount: 1,
5769
autoscaling: { enabled: false },
5870
enableServiceAutoDiscovery: true,
59-
persistentStorageVolumePath: '/data/db',
71+
persistentStorageVolumePath,
6072
dockerCommand: ['mongod', '--port', port.toString()],
6173
assignPublicIp: false,
6274
subnetIds: privateSubnetIds,

0 commit comments

Comments
 (0)