José Ribeiro
06/04/2021, 9:13 PM[100%] fail: Bucket named 'cdk-hnb659fds-assets-***-us-east-2' exists, but not in account ***. Wrong account?
José Ribeiro
06/04/2021, 10:11 PMbucketName
from the CDK script to the lambda function. However, when that’s executed locally, the environment definition in function.environment
doesn’t get applied (only when this is deployed) and thus I’m stuck with my env vars defined locally. Therefore, my questions are 1) should SST be defining those env vars instead? 2) if not, would you guys have any suggestions on how to make the stack output available to my python code?José Ribeiro
06/07/2021, 7:20 PMBill Koch
06/07/2021, 8:24 PM// index.ts
import PeopleStack from './people-stack';
import PlanetsStack from './planets-stack';
import SharedStack from './shared-stack';
import * as sst from '@serverless-stack/resources';
export default function main(app: <http://sst.App|sst.App>): void {
app.setDefaultFunctionProps({
runtime: 'nodejs12.x'
});
const shared = new SharedStack(app, 'shared-stack');
new PeopleStack(app, 'people-stack', shared);
new PlanetsStack(app, 'planets-stack', shared);
}
// shared-stack.ts
import * as sst from '@serverless-stack/resources';
import { IRestApi, RestApi } from '@aws-cdk/aws-apigateway';
export default class SharedStack extends sst.Stack {
public readonly restApi: IRestApi;
constructor(scope: <http://sst.App|sst.App>, id: string, props?: sst.StackProps) {
super(scope, id, props);
this.restApi = <IRestApi> new RestApi(this, `${scope.stage}-sst-demo`);
}
}
// people-stack.ts
import * as sst from '@serverless-stack/resources';
import SharedStack from './shared-stack';
export default class PeopleStack extends sst.Stack {
constructor(scope: <http://sst.App|sst.App>, id: string, shared: SharedStack, props?: sst.StackProps) {
super(scope, id, props);
const api = new sst.ApiGatewayV1Api(this, "Api", {
restApi: shared.restApi,
routes: {
"GET /people/{id}": "src/people/lambda.handler",
},
});
this.addOutputs({
"ApiEndpoint": api.url,
});
}
}
// planets-stack.ts
import * as sst from '@serverless-stack/resources';
import SharedStack from './shared-stack';
export default class PlanetsStack extends sst.Stack {
constructor(scope: <http://sst.App|sst.App>, id: string, shared: SharedStack, props?: sst.StackProps) {
super(scope, id, props);
const api = new sst.ApiGatewayV1Api(this, "Api", {
restApi: shared.restApi,
routes: {
"GET /planets/{id}": "src/planets/lambda.handler",
},
});
this.addOutputs({
"ApiEndpoint": api.url,
});
}
}
With the above setup, I get the following error when trying to `npx sst build`:
Error: 'dev-sst-demo-shared-stack' depends on 'dev-sst-demo-people-stack' (dev-sst-demo-shared-stack -> dev-sst-demo-people-stack/Api/Lambda_GET_--people--{id}/Resource.Arn). Adding this dependency (dev-sst-demo-people-stack -> dev-sst-demo-shared-stack/dev-sst-demo/Resource.Ref) would create a cyclic reference.
at PeopleStack._addAssemblyDependency (/Users/kochwm/dev/sst/sst-demo/node_modules/@aws-cdk/core/lib/stack.ts:730:13)
at Object.addDependency (/Users/kochwm/dev/sst/sst-demo/node_modules/@aws-cdk/core/lib/deps.ts:52:20)
at PeopleStack.addDependency (/Users/kochwm/dev/sst/sst-demo/node_modules/@aws-cdk/core/lib/stack.ts:485:5)
at resolveValue (/Users/kochwm/dev/sst/sst-demo/node_modules/@aws-cdk/core/lib/private/refs.ts:100:12)
at Object.resolveReferences (/Users/kochwm/dev/sst/sst-demo/node_modules/@aws-cdk/core/lib/private/refs.ts:30:24)
at Object.prepareApp (/Users/kochwm/dev/sst/sst-demo/node_modules/@aws-cdk/core/lib/private/prepare-app.ts:31:3)
at Object.synthesize (/Users/kochwm/dev/sst/sst-demo/node_modules/@aws-cdk/core/lib/private/synthesis.ts:24:3)
at App.synth (/Users/kochwm/dev/sst/sst-demo/node_modules/@aws-cdk/core/lib/stage.ts:180:23)
at App.synth (/Users/kochwm/dev/sst/sst-demo/node_modules/@serverless-stack/resources/src/App.ts:199:33)
at process.<anonymous> (/Users/kochwm/dev/sst/sst-demo/node_modules/@aws-cdk/core/lib/app.ts:123:45)
Any help would be greatly appreciated!steve gates
06/07/2021, 9:18 PMSam Frampton
06/07/2021, 11:01 PMERROR: Serverless Pro Error: You are not currently logged in.
José Ribeiro
06/09/2021, 7:43 PMthdxr
06/10/2021, 3:05 PMAshishkumar Pandey
06/10/2021, 10:14 PMcommonjs
to esnext
and I’m already targeting es2018
. I also did switch my function runtime to use Node 14.x but I still get transpilation error saying that top-level await isn’t supported, any ideas?Albert Gao
06/11/2021, 5:06 AMBill Koch
06/11/2021, 6:37 PM// MyStack.ts
import * as sst from "@serverless-stack/resources";
import { Deployment, RestApi, Stage } from "@aws-cdk/aws-apigateway";
export default class MyStack extends sst.Stack {
constructor(scope: <http://sst.App|sst.App>, id: string, props?: sst.StackProps) {
super(scope, id, props);
const apiGateway = RestApi.fromRestApiAttributes(this, "MyRestApi", {
restApiId: "8w6b74ksx0",
rootResourceId: "6lhf5t9hje",
});
const deployment = new Deployment(this, `${scope.stage}-deployment`, {
api: apiGateway
});
const stage = new Stage(this, `${scope.stage}-stage`, {
deployment: deployment,
stageName: scope.stage
});
apiGateway.deploymentStage = stage;
// Create a HTTP API
const api = new sst.ApiGatewayV1Api(this, "Api", {
restApi: apiGateway,
importedPaths: {
"/serverless": "tvg3ia"
},
routes: {
"GET /serverless/hello": "src/lambda.handler",
},
});
}
}
Any help would be greatly appreciated!Albert Gao
06/13/2021, 1:57 AMMr.9715
06/13/2021, 10:44 AMconst distribution = cloudfront.Distribution.fromDistributionAttributes(this, name('cdn'), {
distributionId: cdk.Fn.getAtt(name('distName'), 'app1devDistID'),
domainName: siteDomain
});
The above code works but this distribution
object doesn't have any methods. only a few properties.Ashishkumar Pandey
06/13/2021, 5:52 PMSimon Reilly
06/14/2021, 7:36 AMsst.Auth
construct, but I don't need an identity pool. reason for using the construct is; it handles permissions for triggers, creates the user pool, creates the app client, has sensible defaults. Reason I am not using identity pools is because I am working with multi-tenancy and need to create policies for data isolation. Is there any way to turn identity pool generation off for the Auth construct?Mitja O
06/14/2021, 12:02 PMArtem Kalantai
06/14/2021, 2:16 PMMr.9715
06/15/2021, 4:28 AMgio
06/15/2021, 5:48 AMTomasz Michalak
06/15/2021, 10:11 AMCloudFront
and the Api
construct?thdxr
06/15/2021, 2:12 PMthdxr
06/15/2021, 3:05 PMDennis Dang
06/16/2021, 6:31 AMGabriel
06/16/2021, 8:39 AMAlejandro Inestal
06/17/2021, 12:51 PMAlex Price
06/17/2021, 3:28 PMauthorisationType
, but I can't see it mentioned for AppSync.Dan Van Brunt
06/17/2021, 4:23 PMcache-control
settings to files uploaded by StaticSite?
The issue is when those cache control settings are very specific, like with gatsbyjs.
I can only seem to get it to work on FIRST upload if I use..
1. 3x deployments
2. order the deployments with deps
3. prune only on first deploy
However, on preceeding deploys, if you change a file name (or delete file) that impacts only say the 2nd deployment package, then you will have the old file as an orphan.
Would LOVE some ideas on how to resolve this limitation.
Other things I’ve half-baked-considered:
• running aws s3 cp bucket bucket
to retroactively update cache control settings.
◦ many challenges here…
◦ time consuming looping throw assets twice
◦ can’t be built into a Construct (unless rewriting the deploy construct) since it would need to have the target bucket already deployed/created.
• using programmatic CDK deploy and using execSync
to upload the assets AFTER CDK deploys.
Special Note:
It appears that aws cli's s3 sync
--delete option takes into account the whole directory of files and NOT just the ones the command is filtering on.
However, `s3deploy.BucketDeployment`’s prune option ONLY takes into account the filtered files. This is the crux of the issue. That and there seems to be no way to have 1x single deployment that handles multiple sources “and their associated cache control settings”.
Anyone with experience with this stuff with some ideas, please share. Cheers!Gabriel Gordon-Hall
06/17/2021, 7:39 PMsst start
, but when I run sst deploy
I get the following error:
2021-06-17T19:18:15.874Z undefined ERROR Uncaught Exception {
"errorType": "Runtime.ImportModuleError",
"errorMessage": "Error: Cannot find module '../../dialects/postgres/index.js'\nRequire stack:\n- /var/task/invoke.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
"stack": [
"Runtime.ImportModuleError: Error: Cannot find module '../../dialects/postgres/index.js'",
"Require stack:",
"- /var/task/invoke.js",
"- /var/runtime/UserFunction.js",
"- /var/runtime/index.js",
" at _loadUserApp (/var/runtime/UserFunction.js:100:13)",
" at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)",
" at Object.<anonymous> (/var/runtime/index.js:43:30)",
" at Module._compile (internal/modules/cjs/loader.js:999:30)",
" at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)",
" at Module.load (internal/modules/cjs/loader.js:863:32)",
" at Function.Module._load (internal/modules/cjs/loader.js:708:14)",
" at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)",
" at internal/main/run_main_module.js:17:47"
]
}
It’s odd because I can see knex/lib/dialects/postgres/index.js
in my node modules folder. I also have pg installed. I have tried explicitly importing pg in my lambda but to no avail.
Here’s the lambda code:
import Knex from "knex";
const pgEnv = process.env.POSTGRES || "";
const config = {
client: "pg",
connection: pgEnv,
};
const knex = Knex(config);
I found a webpack workaround for this error is to add the following to the `webpack.config.js`:
module.exports = {
entry: slsw.lib.entries,
target: "node",
externals: { knex: "commonjs knex" },
};
Is there a similar workaround that would be compatible with SST?
Thanks!Simon Reilly
06/18/2021, 6:28 AMError: Cannot find asset at /home/simon/code/projects/event-bridge/.build/lib/runtime
at new AssetStaging (/home/simon/code/projects/event-bridge/node_modules/@aws-cdk/core/lib/asset-staging.ts:170:13)
at new Asset (/home/simon/code/projects/event-bridge/node_modules/@aws-cdk/aws-s3-assets/lib/asset.ts:127:21)
at AssetCode.bind (/home/simon/code/projects/event-bridge/node_modules/@aws-cdk/aws-lambda/lib/code.ts:277:20)
at new Function3 (/home/simon/code/projects/event-bridge/node_modules/@aws-cdk/aws-lambda/lib/function.ts:583:29)
at SingletonFunction.ensureLambda (/home/simon/code/projects/event-bridge/node_modules/@aws-cdk/aws-lambda/lib/singleton-lambda.ts:134:12)
at new SingletonFunction (/home/simon/code/projects/event-bridge/node_modules/@aws-cdk/aws-lambda/lib/singleton-lambda.ts:56:32)
at new AwsCustomResource (/home/simon/code/projects/event-bridge/node_modules/@aws-cdk/custom-resources/lib/aws-custom-resource/aws-custom-resource.ts:360:22)
at new LogGroupResourcePolicy (/home/simon/code/projects/event-bridge/node_modules/@aws-cdk/aws-events-targets/lib/log-group-resource-policy.ts:34:5)
at CloudWatchLogGroup2.bind (/home/simon/code/projects/event-bridge/node_modules/@aws-cdk/aws-events-targets/lib/log-group.ts:38:7)
at Rule2.addTarget (/home/simon/code/projects/event-bridge/node_modules/@aws-cdk/aws-events/lib/rule.ts:166:32)
When running sst test
the lambda gets built correctly:
$ tree -L 1 .build/
.build/
├── eslint.js
├── lib
├── run.js
├── src-lambda-main-1623997587633
├── sst-debug.log
└── sst-merged.json
When running deploy the lambda does not build sst deploy
$ tree -L 1 .build/
.build/
├── cdk.out
├── eslint.js
├── lib
├── run.js
├── sst-debug.log
├── sst-merged.json
└── sst-start-cache.json
Mr.9715
06/19/2021, 4:29 PM