I am trying to provision aws ECS using aws cdk with sst in seed. And I got this issue saying command not found: sst
The logs says this:
$ cd /tmp/seed/source
INFO: before_build hook not found. You can define it in your build spec.
INFO: Learn more about adding a build spec - seed.run/docs/adding-a-build-spec
$ cd /tmp/seed/source/backend/apollo-sst-test
$ npx sst build --stage devops --region ap-southeast-2 --verbose
npx: installed 1 in 1.171s
command not found: sst
ERROR: There was an error synthesizing your app.
INFO: Build completed in 2m 49s. Used 0 build minutes.
Mystack.js code is
import * as sst from "@serverless-stack/resources";
import * as ec2 from "@aws-cdk/aws-ec2";
import * as ecs from "@aws-cdk/aws-ecs";
import * as ecs_patterns from "@aws-cdk/aws-ecs-patterns";
import * as ecr from "@aws-cdk/aws-ecr";
import { DockerImageAsset } from '@aws-cdk/aws-ecr-assets';
import path from "path";
import process from "process";
export default class MyStack extends sst.Stack {
constructor(scope, id, props) {
super(scope, id, props);
// Define your stack
const vpc = new ec2.Vpc(this, "myvpc", {
maxAzs: 2 // Default is all AZs in region
});
const cluster = new ecs.Cluster(this, "mycluster", {
vpc: vpc
});
//#endregionconst repo = new ecs.RepositoryImage("apollo-server");
// const asset = new DockerImageAsset(this, 'MyBuildImage', {
// directory: path.join(__dirname, '../../apollo')
// });
const repo = ecr.Repository.fromRepositoryName(this, "apollo-server-2", "apollo-server-2");
// Create a load-balanced Fargate service and make it public
const loadBalancedFargateService = new ecs_patterns.ApplicationLoadBalancedFargateService(this, "myfargate-alb", {
cluster: cluster, // Required
cpu: 256, // Default is 256
desiredCount: 1, // Default is
taskImageOptions: { image: ecs.ContainerImage.fromEcrRepository(repo)},
memoryLimitMiB: 512, // Default is 512
publicLoadBalancer: true,// Default is false
environment: {
stage: process.env.stage,
cognitoConfig: `https://build-config-bucket-${process.env.stage}.s3-ap-southeast-2.amazonaws.com/cognito-config.json`,
databaseConfig: `https://build-config-bucket-${process.env.stage}.s3-ap-southeast-2.amazonaws.com/database-config.json`,
erwteConfig: `https://build-config-bucket-${process.env.stage}.s3-ap-southeast-2.amazonaws.com/erwte-config.json`
}
});
loadBalancedFargateService.targetGroup.configureHealthCheck({
path: "/.well-known/apollo/server-health",
});
}
}