Here out IaC project structure:
./
├── cdk.context.json
├── package.json
├── package-lock.json
├── README.md
├── sst.json
└── stacks
├── common
│ ├── Msk.js
│ └── Vpc.js
├── index.js
├── posiciones
│ ├── Consumer.js
│ └── DocumentDB.js
└── vistas
├── Api.js
└── Database.js
sst.json
is:
{
"name": "rmo-serverless",
"region": "us-west-2",
"main": "stacks/index.js"
}
and stacks/index.js
:
import { App } from "@serverless-stack/resources";
import { Api } from "./vistas/Api";
import { Database } from "./vistas/Database";
import { Vpc } from "./common/Vpc";
import { Msk } from "./common/Msk";
import { Consumer } from "./posiciones/Consumer";
import { DocumentDB } from "./posiciones/DocumentDB";
/**
* @param {App} app
*/
export default function (app) {
app.setDefaultFunctionProps({ //not needed
runtime: "nodejs14.x",
});
app.stack(Vpc)
.stack(Msk)
.stack(Database)
.stack(DocumentDB)
.stack(Consumer)
.stack(Api);
}
As I mentioned above, we're infrastructure code (sst) and services code (lambdas), in different repositories.
Currently, we're creating our pipelines. In short, we have two pipelines:
- 1 pipeline to Deploy indrastructure: documentdb, rds, msk, vpc
- N pipeline (1 for each) services: lambdas and api gateway
What we are trying to get is that when a service code is pushed on branch, it only re-deploy services related elements, lambdas...
Problem here, is how could we only deploy infrastructure items (documentdb, rds, msk, vpc)? Or how could we deploy only service items (lambdas, api)?
Any suggestions in order to best organize sst project?