Kelly Davis
06/01/2022, 5:36 PMERROR build_failure: The function [FUNCTION_NAME] failed to build
when I invoke the associated endpoint. It is a Go lambda. I have the sst.json at the root of my repo, and then the go code is in a subfolder "foo". The srcPath prop is set to "foo". Any ideas?Frank
Kelly Davis
06/01/2022, 9:41 PMKelly Davis
06/01/2022, 9:43 PMKelly Davis
06/01/2022, 9:45 PMKelly Davis
06/01/2022, 9:47 PMFrank
Kelly Davis
06/01/2022, 9:49 PMFrank
Kelly Davis
06/01/2022, 10:04 PMnpx sst update x.x.x
does not make any changes to the package json. For example, I just ran it and I got:
Updating @serverless-stack/cli to 0.59.1
Updating @serverless-stack/resources to 0.59.1
Updating @aws-cdk/assert@1.138.0
Updating @aws-cdk/aws-iam@1.138.0
Updating @aws-cdk/aws-ses@1.138.0
Updating @aws-cdk/aws-wafv2@1.138.0
Updating @aws-cdk/core@1.138.0
SST: 0.57.4
CDK: 1.138.0
Frank
Kelly Davis
06/01/2022, 10:07 PMFrank
"@serverless-stack/cli": "0.59.1",
"@serverless-stack/resources": "0.59.1",
2. Remove all @aws-cdk/*
ones
3. Add
"aws-cdk-lib": "2.7.0",
Kelly Davis
06/01/2022, 10:13 PMKelly Davis
06/01/2022, 11:04 PMkldavis-tina-cloud-stack-debug-stack: deploying...
❌ kldavis-tina-cloud-stack-debug-stack failed: Error: kldavis-tina-cloud-stack-debug-stack: This CDK deployment requires bootstrap stack version '6', found '5'. Please run 'cdk bootstrap'.
at CloudFormationDeployments.validateBootstrapStackVersion (/Users/kldavis/projects/teams-serverless/node_modules/aws-cdk/lib/api/cloudformation-deployments.ts:440:13)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at CloudFormationDeployments.publishStackAssets (/Users/kldavis/projects/teams-serverless/node_modules/aws-cdk/lib/api/cloudformation-deployments.ts:415:7)
at CloudFormationDeployments.deployStack (/Users/kldavis/projects/teams-serverless/node_modules/aws-cdk/lib/api/cloudformation-deployments.ts:262:5)
at CdkToolkit.deploy (/Users/kldavis/projects/teams-serverless/node_modules/aws-cdk/lib/cdk-toolkit.ts:199:24)
at initCommandLine (/Users/kldavis/projects/teams-serverless/node_modules/aws-cdk/bin/cdk.ts:268:9)
kldavis-tina-cloud-stack-debug-stack: This CDK deployment requires bootstrap stack version '6', found '5'. Please run 'cdk bootstrap'.
❌ kldavis-tina-cloud-stack-debug-stack failed: The kldavis-tina-cloud-stack-debug-stack stack failed to deploy.
I tried deleting the debug stack but it didn't resolve it. Does this mean the CDKToolkit stack needs to be updated?Kelly Davis
06/01/2022, 11:56 PMsst cdk bootstrap
but I get this error:
Error: construct does not have an associated node. All constructs must extend the "Construct" base class
at Function.of (/Users/kldavis/projects/teams-serverless/node_modules/constructs/src/construct.ts:21:13)
at new Node (/Users/kldavis/projects/teams-serverless/node_modules/constructs/src/construct.ts:58:12)
at Object.createNode (/Users/kldavis/projects/teams-serverless/node_modules/constructs/src/construct.ts:407:91)
at new Construct (/Users/kldavis/projects/teams-serverless/node_modules/constructs/src/construct.ts:409:26)
at new Resource (/Users/kldavis/projects/teams-serverless/node_modules/aws-cdk-lib/core/lib/resource.ts:70:5)
at new TableBase (/Users/kldavis/projects/teams-serverless/node_modules/aws-cdk-lib/aws-dynamodb/lib/table.ts:277:1)
at new Table (/Users/kldavis/projects/teams-serverless/node_modules/aws-cdk-lib/aws-dynamodb/lib/table.ts:680:5)
at IdentityStack.createDynamoTable (/Users/kldavis/projects/teams-serverless/sst/IdentityStack.ts:526:23)
at new IdentityStack (/Users/kldavis/projects/teams-serverless/sst/IdentityStack.ts:78:30)
at Object.main (/Users/kldavis/projects/teams-serverless/sst/index.ts:87:25)
This is originating where a dynamodb table is being createdKelly Davis
06/02/2022, 12:36 AMFrank
Frank
constructs
as a devDep. Feel free to show me the repo if you need anohter pair of eyes 🙂Kelly Davis
06/03/2022, 7:19 PMFrank
Kelly Davis
06/03/2022, 7:22 PMFrank
app
and the scope for the constructs in a stack should be the stack
Kelly Davis
06/03/2022, 7:27 PMexport class SsmParameterReader extends Construct {
private reader: AwsCustomResource
constructor(scope: Construct, name: string, props: SsmParameterReaderProps) {
super(scope, name)
const { parameterName, region } = props
this.reader = new AwsCustomResource(scope, `${name}CustomResource`, {
policy: AwsCustomResourcePolicy.fromStatements([
new iam.PolicyStatement({
effect: iam.Effect.ALLOW,
actions: ['ssm:GetParameter*'],
resources: [
sst.Stack.of(this).formatArn({
service: 'ssm',
region,
resource: 'parameter',
resourceName: parameterName.replace(/^\/+/, ''), // remove leading '/', since formatArn() will add one
}),
],
}),
]),
onUpdate: {
service: 'SSM',
action: 'getParameter',
parameters: {
Name: parameterName,
},
region,
physicalResourceId: PhysicalResourceId.of(Date.now().toString()), // Update physical id to always fetch the latest version
},
})
}
private getParameterValue(): string {
return this.reader.getResponseField('Parameter.Value')
}
get stringValue(): string {
return this.getParameterValue()
}
}
So what should we be extending instead of Construct?Frank
Frank
SsmParameterReader
?Kelly Davis
06/03/2022, 7:33 PMnew ssm.StringParameter(this, 'ssm-value', {
parameterName: <param-name>,
stringValue: `${cloudfrontSecurity.functionArn}:${cloudfrontSecurity.currentVersion.version}`,
})
and then in the frontend stack we read the current version:
const egdeLambdaFunctionArn = new SsmParameterReader(
this,
'LambdaFunctionArnReader',
{
parameterName: <param-name>,
region: 'us-east-1', // lambda@edge region
}
).stringValue
the lambda@edge is rarely updated, so this avoids having cloudformation update it when the frontend stack is updatedFrank
this
in both cases Stack
?Kelly Davis
06/03/2022, 7:35 PMFrank
constructor(scope: Construct, name: string, props: SsmParameterReaderProps) {
with
constructor(scope: sst.Stack, name: string, props: SsmParameterReaderProps) {
Frank
Construct
and including it as a devDep.. but u’d have to manually keep construct
’s version up to dateFrank
Kelly Davis
06/03/2022, 7:38 PMextends
?Frank
sst.Construct
Kelly Davis
06/03/2022, 7:43 PMFrank
Kelly Davis
06/03/2022, 7:44 PMFrank
Kelly Davis
06/03/2022, 7:45 PM