Ross Coundon
05/23/2022, 9:07 PMError: 'some-stage-the-app-sst-coreFunctionsStack' depends on 'some-stage-the-app-sst-marketingStack' (some-stage-the-app-sst-coreFunctionsStack -> some-stage-the-app-sst-marketingStack/marketingBucket/Bucket/Resource.Arn). Adding this dependency (some-stage-the-app-sst-marketingStack -> some-stage-the-app-sst-coreFunctionsStack/resourcePhotoBucket/Bucket/Resource.Ref) would create a cyclic reference.
This implies to me that coreFunctionsStack imports, directly or indirectly, the marketingStack but it doesn’t. However, the opposite is true.
Then the second half of the error that seems to say that importing the resourcePhotoBucket into coreFunctionsStack is the problem but that doesn’t happen either. resourcePhotoBucket is created in coreFunctionsStack and isn’t used at all by marketing Stack.Jeff Hanna
05/24/2022, 12:09 AMesbuild
, which is working, but is there a way to automatically run this esbuild command before every deployment?Tim
05/24/2022, 1:03 AMsst.Api
as a prop. it seems like with functional stacks any stack with a dependency needs to be aware of the stack that exports the resource it needs instead of just the type of the resource itselfShubham Sinha
05/24/2022, 4:34 AMpackage main
import (
"fmt"
"log"
"os"
"<http://github.com/aws/aws-lambda-go/events|github.com/aws/aws-lambda-go/events>"
"<http://github.com/aws/aws-lambda-go/lambda|github.com/aws/aws-lambda-go/lambda>"
"<http://github.com/aws/aws-sdk-go/aws|github.com/aws/aws-sdk-go/aws>"
"<http://github.com/aws/aws-sdk-go/aws/session|github.com/aws/aws-sdk-go/aws/session>"
"<http://github.com/aws/aws-sdk-go/service/dynamodb|github.com/aws/aws-sdk-go/service/dynamodb>"
"<http://github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute|github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute>"
)
type Project struct {
Description string `json:"description"`
}
func Handler(request events.APIGatewayV2HTTPRequest) (events.APIGatewayProxyResponse, error) {
sess := session.Must(session.NewSessionWithOptions(session.Options{
SharedConfigState: session.SharedConfigEnable,
}))
svc := dynamodb.New(sess)
tableName := os.Getenv("table")
result, err := svc.GetItem(&dynamodb.GetItemInput{
TableName: aws.String(tableName),
Key: map[string]*dynamodb.AttributeValue{
"Project": {
S: aws.String("Ecommerce"),
},
},
})
if err != nil {
log.Fatalf("Got error calling GetItem: %s", err)
}
project := Project{}
err = dynamodbattribute.UnmarshalMap(result.Item, &project)
if err != nil {
panic(fmt.Sprintf("Failed to unmarshal Record, %v", err))
}
return events.APIGatewayProxyResponse{
Body: project.Description,
StatusCode: 200,
}, nil
}
func main() {
lambda.Start(Handler)
}
Got error calling GetItem: ValidationException: The provided key element does not match the schema
status code: 400, request id: 1VH9CC6VVG7O2TVQSRV9PJSVPNVV4KQNSO5AEMVJF66Q9ASUAAJGKarolis Stulgys
05/24/2022, 7:05 AMlayers
and why do we need them in sst
?
When I look to prisma
example I just don't get it https://github.com/serverless-stack/serverless-stack/blob/master/examples/prisma/stacks/MyStack.tsShahan
05/24/2022, 8:48 AMNeil Balcombe
05/24/2022, 1:59 PMAdrián Mouly
05/24/2022, 5:19 PMKevin Grimm
05/24/2022, 11:21 PM503 ERROR
The request could not be satisfied.
The Lambda function associated with the CloudFront distribution is invalid or doesn't have the required permissions. We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.
Generated by cloudfront (CloudFront)
Request ID: <Request_ID>
Couple notes/observations as I continue to investigate this:
• The most suspect change I can think of are updates to the CSP policy to accept traffic from Google Analytics. Adding the code below for reference.
• I saw from several past threads that this could be a Next JS issue. Could also be a me issue as I have overlooked stuff in the past (and will again 😃 )
// next.config.js
const ContentSecurityPolicy = `
default-src
'self';
script-src
<https://www.googletagmanager.com/>
'self'
'unsafe-eval'
'unsafe-inline';
style-src
'self'
'unsafe-inline';
img-src
*
blob:
data:;
media-src
'none';
connect-src
*;
font-src
'self';
frame-src
'none';
`;
const securityHeaders = [
// <https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP>
{
key: "Content-Security-Policy",
value: ContentSecurityPolicy.replace(/\n/g, ""),
},
// ... other headers
];
I'm also exploring the CNAMEs associated with my hosted zone... seems like the # has increased since the last deployment. What's also curious is that I've identified two separate ACM certificates with the same underlying CNAME (also referencing the same domain). That strikes me as odd so may just rm -rf
the stack and see if an infrastructure reset solves the issue. If that's the case though I'll likely do additional research into past npx sst deploy
commands since I'm not generating any manual infraJason S
05/25/2022, 2:34 AMLiran Farage
05/25/2022, 8:41 AMpnpm
, I get the following error, but locally it works:
ERROR: Failed to run: pnpm ls --filter-prod "...[0e5368e04745512d0d8f3d178084727371d97fe0]" --json
Would appreciate your help 🙏
@Frank @Jaysforman
05/25/2022, 8:46 AMdefaultFunctionProps: {
environment: {
someVar: value
}
}
Neil Balcombe
05/25/2022, 10:50 AMimport { Amplify } from 'aws-amplify';
I get the following error in my app.
Uncaught ReferenceError: global is not defined
at node_modules/buffer/index.js (index.js:43:30)
at __require2 (chunk-ZVZOEM2G.js?v=9600c6f0:35:50)
at AuthenticationHelper.js:5:24
Any ideas?Malike.Z
05/25/2022, 1:47 PMMalike.Z
05/25/2022, 2:00 PMNeil Balcombe
05/25/2022, 2:20 PM// Create Api
const api = new Api(stack, 'Api', {
defaults: {
authorizer: 'iam',
},
routes: {
'GET /private': 'functions/private.handler',
'GET /public': {
function: 'functions/public.handler',
authorizer: 'none',
},
},
});
// Create auth provider
const auth = new Auth(stack, 'Auth', {
login: ['email'],
});
// Allow authenticated users invoke API
auth.attachPermissionsForAuthUsers([api]);
// Create a React Static Site
const site = new ViteStaticSite(stack, 'Site', {
path: 'frontend',
environment: {
VITE_APP_API_URL: api.url,
VITE_APP_USER_POOL_ID: auth.userPoolId,
VITE_APP_IDENTITY_POOL_ID: auth.cognitoIdentityPoolId || '',
VITE_APP_USER_POOL_CLIENT_ID: auth.userPoolClientId,
VITE_APP_REGION: app.region,
},
});
I'm managing the login with Amplify and again using Amplify to call the API as such.
API.get("my-api", "/private")
.then((response) => console.log(response))
.catch((e) => console.log(e));
But I'm getting 403 errors when I call the endpoint.
I thought that by using the Amplify 'API' class it what use the logged in user, is this not the case? Am I bound to using the API class or can I achieve the same with using the fetch API?Nathan
05/25/2022, 2:37 PMGeoff Seemueller
05/25/2022, 3:55 PMkritstabs
05/25/2022, 4:42 PM2022-05-25T16:08:35.058Z undefined ERROR Uncaught Exception {
"errorType": "Runtime.UserCodeSyntaxError",
"errorMessage": "SyntaxError: Cannot use import statement outside a module",
"stack": [
"Runtime.UserCodeSyntaxError: SyntaxError: Cannot use import statement outside a module",
" at _loadUserApp (file:///var/runtime/index.mjs:724:17)",
" at async Object.module.exports.load (file:///var/runtime/index.mjs:741:21)",
" at async file:///var/runtime/index.mjs:781:15",
" at async file:///var/runtime/index.mjs:4:1"
]
}
Devin
05/25/2022, 4:46 PM<http://design.mycoolapp.com|design.mycoolapp.com>
Kujtim Hoxha
05/25/2022, 4:52 PM<http://yourdomain.com/api|yourdomain.com/api>
and you static site under <http://yourdomain.com|yourdomain.com>
, I am asking because this way I would prevent cors and preflight (OPTION) callsSam Hulick
05/25/2022, 4:59 PMFunction
with a handler file ending in .mjs
?Ty
05/25/2022, 6:14 PMsst start
where I end up getting the following error:
Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only file and data URLs are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol
'c:'
at new NodeError (node:internal/errors:371:5)
at throwIfUnsupportedURLProtocol (node:internal/modules/esm/resolve:1033:11)
at defaultResolve (node:internal/modules/esm/resolve:1103:3)
at ESMLoader.resolve (node:internal/modules/esm/loader:530:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:251:18)
at ESMLoader.import (node:internal/modules/esm/loader:332:22)
at importModuleDynamically (node:internal/modules/esm/translators:106:35)
at importModuleDynamicallyCallback (node:internal/process/esm_loader:35:14)
at file:///C:/_projects/junk/csharptesting/node_modules/@serverless-stack/cli/assets/debug-stack/bin/index.mjs:20:46 {
code: 'ERR_UNSUPPORTED_ESM_URL_SCHEME'
Any ideas of what I can try?Rudi
05/25/2022, 6:16 PM===============
Deploying app
===============
/home/rudi/projects/notes/node_modules/aws-cdk-lib/aws-autoscaling/lib/auto-scaling-group.d.ts (672,15): Cannot find name 'Set'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later.
670. */
671. _metrics: Set<GroupMetric>;
672. constructor(...metrics: GroupMetric[]);
Deploying stacks
Michael Robellard
05/25/2022, 7:18 PM(chartflow) Michaels-MBP-3:chartflow dramus$ AWS_PROFILE=chartflow npx sst build
Using stage: mike-local
Preparing your SST app
Synthesizing CDK
ReferenceError: __dirname is not defined in ES module scope
at bundle (file:///Users/dramus/chartflow/node_modules/@serverless-stack/core/dist/runtime/handler/pythonBundling.js:40:31)
at Object.bundle (file:///Users/dramus/chartflow/node_modules/@serverless-stack/core/dist/runtime/handler/python.js:33:27)
at Module.bundle (file:///Users/dramus/chartflow/node_modules/@serverless-stack/core/dist/runtime/handler/index.js:16:16)
at new Function (file:///Users/dramus/chartflow/node_modules/@serverless-stack/resources/dist/Function.js:222:45)
at Function.fromDefinition (file:///Users/dramus/chartflow/node_modules/@serverless-stack/resources/dist/Function.js:405:20)
at Table.addConsumer (file:///Users/dramus/chartflow/node_modules/@serverless-stack/resources/dist/Table.js:300:23)
at new Table (file:///Users/dramus/chartflow/node_modules/@serverless-stack/resources/dist/Table.js:38:22)
at new DynamodbStack (file:///Users/dramus/chartflow/.build/lib/index.js:14:26)
at Module.main (file:///Users/dramus/chartflow/.build/lib/index.js:349:24)
at file:///Users/dramus/chartflow/.build/run.mjs:92:16
There was an error synthesizing your app.
This doesn't seem to be coming from anything directly in my code, __dirname only appears in the .build directoryMichael Robellard
05/25/2022, 8:15 PMError: Cannot set the "srcPath" to the project root for the "Lambda_POST_/login_check" function.
Should the Default settings for the api be default or defaultFunctionProps, or something else, I tried both and seem to still be having the issue. My Lambda functions are Python so srcPath is required for requirements.txt
Full Traceback:
Error: Cannot set the "srcPath" to the project root for the "Lambda_POST_/login_check" function.
at new Function (file:///Users/dramus/chartflow/node_modules/@serverless-stack/resources/dist/Function.js:108:23)
at Function.fromDefinition (file:///Users/dramus/chartflow/node_modules/@serverless-stack/resources/dist/Function.js:389:20)
at Api.createFunctionIntegration (file:///Users/dramus/chartflow/node_modules/@serverless-stack/resources/dist/Api.js:491:27)
at file:///Users/dramus/chartflow/node_modules/@serverless-stack/resources/dist/Api.js:378:26
at Api.addRoute (file:///Users/dramus/chartflow/node_modules/@serverless-stack/resources/dist/Api.js:408:11)
at file:///Users/dramus/chartflow/node_modules/@serverless-stack/resources/dist/Api.js:101:18
at Array.forEach (<anonymous>)
at Api.addRoutes (file:///Users/dramus/chartflow/node_modules/@serverless-stack/resources/dist/Api.js:100:29)
at new Api (file:///Users/dramus/chartflow/node_modules/@serverless-stack/resources/dist/Api.js:50:14)
at new ApiStack (file:///Users/dramus/chartflow/.build/lib/index.js:183:16)
Michael Robellard
05/25/2022, 8:24 PMthis.api = new sst.Api(this, "Api", {
customDomain: {
hostedZone: "<http://chartflow.io|chartflow.io>",
domainName: apiurl,
cdk: {
certificate: this.cert
}
},
cors:{
allowOrigins: [`https://${weburl}${scope.local ? ":3000" : ""}`],
allowMethods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
allowHeaders: ["Access-Control-Allow-Headers", "Origin", "Accept", "X-Requested-With", "Content-Type",
"Access-Control-Request-Method", "Access-Control-Request-Headers"],
allowCredentials: true
},
defaultFunctionProps: {
environment: {
SEARCH_ENDPOINT: props.opensearch_domain.domainEndpoint,
STAGE: scope.stage,
UPLOAD_BUCKET: props.s3_bucket.bucketName,
},
permissions: [
new iam.PolicyStatement({
actions: ["ssm:GetParameter", "ssm:GetParameters", "ssm:GetParametersByPath"],
resources: ["*"],
}),
],
srcPath: "backend/"
},
routes: {
//user
"POST /login_check": "services/api/user/login_check.handler",
...
This is the original defaultFunctionProps, which worked fine in 0.6.9, I also tried changing it to default and I get the same errorJean Rumeau
05/25/2022, 8:26 PMMichael Robellard
05/25/2022, 9:10 PMCannot find global type 'Array'.
Cannot find global type 'Boolean'.
Cannot find global type 'CallableFunction'.
Cannot find global type 'Function'.
Cannot find global type 'IArguments'.
Cannot find global type 'NewableFunction'.
Cannot find global type 'Number'.
Cannot find global type 'RegExp'.
Cannot find global type 'String'.
Library 'es2021' specified in compilerOptions
...
/Users/dramus/chartflow/stacks/dynamodb.js (21,13): Object literal may only specify known properties, and 'timeToLiveAttribute' does not exist in type 'TableProps'.
19. },
20. timeToLiveAttribute: "expires_at",
21. stream: true,
/Users/dramus/chartflow/stacks/dynamodb.js (72,21): Object literal may only specify known properties, and 'replicationRegions' does not exist in type '{ table?: any; }'.
70. cdk: {
71. replicationRegions: replicationRegions,
72. }
/Users/dramus/chartflow/stacks/dynamodb.js (80,15): Object literal may only specify known properties, and 'dynamodbtable' does not exist in type 'TableProps'.
78. this.globalchartflowdata = new sst.Table(this, "Table", {
79. dynamodbtable: dynamodb.Table.fromTableArn(this, "ImportedTable", tableArn),
80. });
/Users/dramus/chartflow/stacks/index.js (15,13): Property 'push' does not exist on type '{}'.
13. if(app.stage.startsWith("dev")){
14. regions.push("ap-southeast-1");
15. }
/Users/dramus/chartflow/stacks/s3.js (23,21): Object literal may only specify known properties, and 'publicReadAccess' does not exist in type '{ bucket?: BucketProps | Bucket; }'.
21. cdk: {
22. publicReadAccess: true
23. }
Deploying stacksFJ
05/25/2022, 11:28 PMPreparing your SST app
=======================
Deploying debug stack
=======================
node:internal/errors:465
ErrorCaptureStackTrace(err);
^
Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'd:'
at new NodeError (node:internal/errors:372:5)
at throwIfUnsupportedURLScheme (node:internal/modules/esm/resolve:1120:11)
at defaultResolve (node:internal/modules/esm/resolve:1200:3)
at ESMLoader.resolve (node:internal/modules/esm/loader:580:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:294:18)
at ESMLoader.import (node:internal/modules/esm/loader:380:22)
at importModuleDynamically (node:internal/modules/esm/translators:106:35)
at importModuleDynamicallyCallback (node:internal/process/esm_loader:35:14)
at file:///D:/Projects/MyProject/sst/node_modules/@serverless-stack/cli/assets/debug-stack/bin/index.mjs:20:46 {
code: 'ERR_UNSUPPORTED_ESM_URL_SCHEME'
}
There was an error synthesizing your app.