Iamgingertrash
09/09/2021, 2:48 AMAbdul Taleb
09/09/2021, 3:04 AMthis.addOutputs({...})
sync or async? I'm wondering If I can run some code after it that can start an external service that can grab the env variables from sstAbdul Taleb
09/09/2021, 3:22 AMStaticSite
construct and environment variables and it seems that it sets the variables with {{ VARIABLE }}
rather than actually setting the variable, and after build it will inject the variable using some type of text match/find-replace. The problem is that in some static sites, the build happens via webpack and process.env.VARIABLE is handled via webpack's definePlugin
module, which expects the actual value to be set before the build process. Has anyone faced this issue? If yes, how have you solved it? Any help would be appreciated.Job de Noo
09/09/2021, 8:28 AM{'version': '2.0', 'routeKey': 'GET /', 'rawPath': '/', 'rawQueryString': '', 'headers': {'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9', 'accept-encoding': 'gzip, deflate, br', 'accept-language': 'nl-NL,nl;q=0.9,en-NL;q=0.8,en;q=0.7,en-US;q=0.6,fr;q=0.5', 'cache-control': 'max-age=0', 'content-length': '0', 'dnt': '1', 'host': '<http://l7m9q9ic8f.execute-api.us-east-1.amazonaws.com|l7m9q9ic8f.execute-api.us-east-1.amazonaws.com>', 'sec-ch-ua': '"Chromium";v="92", " Not A;Brand";v="99", "Google Chrome";v="92"', 'sec-ch-ua-mobile': '?0', 'sec-fetch-dest': 'document', 'sec-fetch-mode': 'navigate', 'sec-fetch-site': 'none', 'sec-fetch-user': '?1', 'upgrade-insecure-requests': '1', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36', 'x-amzn-trace-id': 'Root=1-6139c317-73c82b1e16bbe783588a6ded', 'x-forwarded-for': '82.170.147.5', 'x-forwarded-port': '443', 'x-forwarded-proto': 'https'}, 'requestContext': {'accountId': '915964404932', 'apiId': 'l7m9q9ic8f', 'domainName': '<http://l7m9q9ic8f.execute-api.us-east-1.amazonaws.com|l7m9q9ic8f.execute-api.us-east-1.amazonaws.com>', 'domainPrefix': 'l7m9q9ic8f', 'http': {'method': 'GET', 'path': '/', 'protocol': 'HTTP/1.1', 'sourceIp': '82.170.147.5', 'userAgent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36'}, 'requestId': 'FYtrwjaDoAMEJkw=', 'routeKey': 'GET /', 'stage': '$default', 'time': '09/Sep/2021:08:17:27 +0000', 'timeEpoch': 1631175447808}, 'isBase64Encoded': False}
SyntaxError: Unexpected token n in JSON at position 0
at JSON.parse (<anonymous>)
at createStrictSyntaxError (/home/jobdenoo/dearhealth/services/poc-sst/my-sst-app/node_modules/body-parser/lib/types/json.js:158:10)
at parse (/home/jobdenoo/dearhealth/services/poc-sst/my-sst-app/node_modules/body-parser/lib/types/json.js:83:15)
at /home/jobdenoo/dearhealth/services/poc-sst/my-sst-app/node_modules/body-parser/lib/read.js:121:18
at invokeCallback (/home/jobdenoo/dearhealth/services/poc-sst/my-sst-app/node_modules/raw-body/index.js:224:16)
at done (/home/jobdenoo/dearhealth/services/poc-sst/my-sst-app/node_modules/raw-body/index.js:213:7)
at IncomingMessage.onEnd (/home/jobdenoo/dearhealth/services/poc-sst/my-sst-app/node_modules/raw-body/index.js:273:7)
at IncomingMessage.emit (events.js:412:35)
at IncomingMessage.emit (domain.js:470:12)
at endReadableNT (internal/streams/readable.js:1317:12)
Traceback (most recent call last):
File "/home/jobdenoo/dearhealth/services/poc-sst/my-sst-app/node_modules/@serverless-stack/cli/scripts/util/bootstrap.py", line 99, in <module>
r = request.urlopen(req, data=data)
File "/usr/lib/python3.8/urllib/request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python3.8/urllib/request.py", line 531, in open
response = meth(req, response)
File "/usr/lib/python3.8/urllib/request.py", line 640, in http_response
response = self.parent.error(
File "/usr/lib/python3.8/urllib/request.py", line 569, in error
return self._call_chain(*args)
File "/usr/lib/python3.8/urllib/request.py", line 502, in _call_chain
result = func(*args)
File "/usr/lib/python3.8/urllib/request.py", line 649, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request
c725cef9-e66c-4ffb-bc5c-5bad18ff538f ERROR Runtime exited with error: exit status 1
Dan Van Brunt
09/09/2021, 6:21 PMParsing error: “parserOptions.project” has been set for @typescript-eslint/parser.
The file does not match your project config: .eslintrc.js.
The file must be included in at least one of the projects provided.
Ayo
09/10/2021, 1:07 AMAyo
09/10/2021, 3:59 AMAyo
09/10/2021, 1:59 PMSam Hulick
09/10/2021, 3:48 PMyarn start
, it prompts me with this:
Look like you're running sst for the first time in this directory. Please enter a stage name you'd like to use locally. Or hit enter to use the one based on your AWS credentials (samh):
this is due to removing stage from sst.json. I’d maybe modify that message, as it’s confusing. should it instead say that --stage
is required?Dan Van Brunt
09/10/2021, 6:42 PMUsage in Lambda: Fetch the SSM values inside a Lambda function using the AWS SDK
as the docs further read.
Perhaps there are two methods here:
1. Use aws-ssm
construct to pass the ssm value at deploy time into something. (Security: it depends, secrets shouldn’t be stored in plain text as lambda env vars)
2. Pass the SSM parameter name into a Lambda as an env var. Then fetch that value inside the function using aws-sdk.
No?Brett Fieber
09/10/2021, 7:07 PMHi
is there a way to reset 2fa on seed.run? (edited)
I don't see the app in my authenticator app and can't loginI'm not seeing anything in the UI and Manage user only lets me modify their Roles.
Dan Van Brunt
09/10/2021, 7:30 PMDan Van Brunt
09/10/2021, 8:36 PMDan Van Brunt
09/10/2021, 8:52 PM[stage]-[app]-[stack]
[stage]-[app]-debug-stack
Dan Van Brunt
09/10/2021, 9:19 PMAso Sun
09/11/2021, 9:48 AMError: Invalid function definition for the "Job" Function
import { Cron, Function } from "@serverless-stack/resources";
this.function = new Function(this, 'scheduled', {
handler: "src/scheduled.main",
environment: {
TABLE_NAME: table.tableName,
}
})
this.cron = new Cron(this, 'cron', {
schedule: "cron(0 1 * * ? *)"
job: {
function: this.function
},
})
this.cron.attachPermissions([table])
max.suster
09/12/2021, 12:31 PMauth.addPermissionsToAuthRole
. I assume this might have been asked before, but I can not find a clear and defintive answer in the context of SST.
Essentially, I have already deployed an Auth sst stack with Cognito User Pools and its working fine for my ReactStaticApp. However, now I have a separate Infrastructure repository in which I created an Api sst stack, but I am struggling to use the same Cognito User pools already deployed for the React app. I have been trying to add IAM authentication (from the already existing User pool) to the Api SST stack by doing something very similar to a solution reported in a previous thread (adding a Policy to an IAM role). My solution gets deployed ok, but does not seem to work (I get HTTP 403 when using my existing Cognito User credentials). I assume this might not work without being able to refer to an instance of the original Auth stack?
Does anyone have a suggestion for reusing an existing Auth/Cognito pools for an Api sst that is deployed in a separate repository? Thanks in advance.Adrián Mouly
09/13/2021, 1:45 AMSerhii Arendarchuk
09/13/2021, 9:22 AMmathewgries
09/13/2021, 3:38 PMAdrián Mouly
09/13/2021, 5:29 PMDan Van Brunt
09/13/2021, 5:58 PMPOST *
)Kelly Davis
09/13/2021, 8:19 PMsst start
and using the StaticSite construct? The issue is that I have a single step where I need to access the deployed static site (to setup some auth) and then the remainder of my access will be through localhost, but at the moment this means I first need to run sst deploy
and after auth I run sst start
.
Also, it seems like sst start
replaces the deployed static site with the placeholder site after a sst deploy
, so if there was an option to suppressing the placeholder deploy, it would also solve my problem.Ollie Camp
09/14/2021, 1:52 PMhttps://${Token[TOKEN.186]}
which then results in the following error error Cannot find a handler file for "https://${Token[TOKEN.186]}"
.
I'm sure I've missed something obvious but I've now been starring at this problem to long to see it!
lib/index.js
import MyStack from "./MyStack";
import AssetsStack from "./AssetsStack";
export default function main(app) {
// Set default runtime for all functions
app.setDefaultFunctionProps({
runtime: "nodejs14.x"
});
const assets = new AssetsStack(app, "assets-stack");
new MyStack(app, "my-stack", { asset_url: assets.url });
}
lib/AssetsStack.js
import { Stack, StaticSite } from "@serverless-stack/resources";
export default class AssetsStack extends Stack {
url
constructor(scope, id, props) {
super(scope, id, props);
// Create a Sattic Site
const assets = new StaticSite(this, "Assets", {
path: 'src/build/assets/'
})
this.url = assets.url
// Show the endpoint in the output
this.addOutputs({
"CloudFrontEndpoint": assets.url
});
}
}
lib/MyStack.js
import { Stack, Api } from "@serverless-stack/resources";
export default class MyStack extends Stack {
constructor(scope, id, props) {
super(scope, id, props);
const { asset_url } = props
// Create a HTTP API
const api = new Api(this, "Api", {
routes: {
"GET /_app": asset_url,
"$default": "src/lambda.handler",
},
});
// Show the endpoint in the output
this.addOutputs({
"ApiEndpoint": api.url
});
}
}
Ayo
09/14/2021, 3:53 PMthdxr
09/14/2021, 6:14 PMStan
09/14/2021, 6:26 PMAbdul Taleb
09/14/2021, 6:57 PMconst apiAuth = new sst.Auth(this, 'auth', {
cognito: {
userPool: myUserPool,
userPoolClient: myUserPoolClient,
},
identityPool: {
allowUnauthenticatedIdentities: false,
identityPoolName: `api-identity-pool-${scope.stage}`,
}
});
const api = new sst.Api(this, 'api', { ...with JWT or Cognito Authorizer.. });
apiAuth.attachUnauthPermissions([api]);
Dan Van Brunt
09/14/2021, 9:00 PMyarn create serverless-stack my-sst-app --language typescript
I then created a folder in the root called /frontend
then I copied all my react-app src into there
then I used the example StaticSite
code…
new StaticSite(this, 'GatsbySite', {
path: 'frontend',
errorPage: '404.html',
buildOutput: 'public',
buildCommand: 'yarn build',
})
then I ran yarn sst deploy
then it ran in a loop over and over, endlessly.
Answer:
Took a sec but I realized that the above example code to yarn build
but the root sst package.json is already set to _"build"_: "sst build",
hence the loop.
What IS the buildCommand supposed to be set to by example?
buildCommand: 'yarn build:frontend',
or
buildCommand: './frontend/yarn build',
Adrián Mouly
09/14/2021, 10:08 PM