Branko Gvoka
07/19/2021, 7:51 PMError: Do not directly set the environment for a stack?
I’ve initialized empty project, added a stack, used AWS_PROFILE and --stage and I’m getting this somehow 🙂 I’ve added later empty environment in both BaseStack and service stack but didnt helpFrank
lib/index.js
?Branko Gvoka
07/19/2021, 7:53 PMimport * as sst from '@serverless-stack/resources';
import ShopifyStack from './ShopifyStack';
import BaseStack from './BaseStack';
export default function main(app: <http://sst.App|sst.App>): void {
// Set default runtime for all functions
app.setDefaultFunctionProps({
environment: {},
runtime: 'nodejs12.x',
});
const { httpApi } = new BaseStack(app, 'base');
new ShopifyStack(app, 'shopify-stack', httpApi);
}
Shopify dummy stack
import { HttpApi } from '@aws-cdk/aws-apigatewayv2';
import * as sst from '@serverless-stack/resources';
interface ShopifyStackProps extends sst.StackProps {
httpApiId: string;
}
const SRC_PATH = 'services/shopify';
export default class ShopifyStack extends sst.Stack {
constructor(scope: <http://sst.App|sst.App>, id: string, props: ShopifyStackProps) {
super(scope, id, props);
const { httpApiId } = props;
new sst.Api(this, 'ShopifyApi', {
defaultFunctionProps: {
environment: {},
},
httpApi: HttpApi.fromHttpApiAttributes(this, 'Api', {
httpApiId,
}),
routes: {
'GET /': `${SRC_PATH}/src/lambda.handler`,
},
});
}
}
Frank
environment for a stackEnvironment for a stack refers to the AWS account Id + AWS region pair that defines where the stack will be deployed to. It’s a CDK concept that SST tries to automatically configure and not expose to the end user.
Frank
environment
variables.Frank
new ShopifyStack(app, 'shopify-stack', httpApi);
to:
new ShopifyStack(app, 'shopify-stack', { httpApi });
Branko Gvoka
07/19/2021, 9:04 PMFrank