Question
Answer
Try removing the `cdk.context.json` file if it is in a weird state. It might also be caused by a typo in the `package.json` file. Make sure to replace `${whoami}` with `$(whoami)`.
Seth Geoghegan
01/24/2022, 3:20 PMThere was an error synthesizing your app
when performing a yarn run start
. I've deployed this app many times and this is the first time I'm seeing this. However, I can manually sst build
and sst deploy
followed by an sst remove
to remove the deployed app. This appears to be limited to the live lambda dev environmentSeth Geoghegan
01/24/2022, 3:20 PM(lib.interpreter-y6Y1OWkN-py3.8) ➜ knock-attribution-service git:(develop) ✗ yarn run start
yarn run v1.22.11
$ AWS_PROFILE=CC-Non-Prod.CC_Engineering_ReadWrite AWS_SDK_LOAD_CONFIG=1 sst start --stage {whoami}
Using stage: {whoami}
Preparing your SST app
=======================
Deploying debug stack
=======================
/Users/sgeoghegan/dev/knock-attribution-service/node_modules/aws-cdk-lib/core/lib/stack.js:1
"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.rootPathTo=exports.Stack=exports.STACK_RESOURCE_LIMIT_CONTEXT=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),fs=require("fs"),path=require("path"),cxschema=require("../../cloud-assembly-schema"),cxapi=require("../../cx-api"),constructs_1=require("constructs"),annotations_1=require("./annotations"),app_1=require("./app"),arn_1=require("./arn"),cfn_element_1=require("./cfn-element"),cfn_fn_1=require("./cfn-fn"),cfn_pseudo_1=require("./cfn-pseudo"),cfn_resource_1=require("./cfn-resource"),context_provider_1=require("./context-provider"),feature_flags_1=require("./feature-flags"),cloudformation_lang_1=require("./private/cloudformation-lang"),logical_id_1=require("./private/logical-id"),resolve_1=require("./private/resolve"),uniqueid_1=require("./private/uniqueid"),STACK_SYMBOL=Symbol.for("@aws-cdk/core.Stack"),MY_STACK_CACHE=Symbol.for("@aws-cdk/core.Stack.myStack");exports.STACK_RESOURCE_LIMIT_CONTEXT="@aws-cdk/core:stackResourceLimit";const VALID_STACK_NAME_REGEX=/^[A-Za-z][A-Za-z0-9-]*$/,MAX_RESOURCES=500;class Stack extends constructs_1.Construct{constructor(scope,id,props={}){var _b,_c,_d;jsiiDeprecationWarnings.aws_cdk_lib_StackProps(props),scope=scope!=null?scope:new <http://app_1.App|app_1.App>({autoSynth:!1,outdir:fs_1.FileSystem.mkdtemp("cdk-test-app-")}),id=id!=null?id:"Default";super(scope,id);this._missingContext=new Array,this._stackDependencies={},this.templateOptions={},Object.defineProperty(this,STACK_SYMBOL,{value:!0}),this._logicalIds=new logical_id_1.LogicalIDs;const{account,region,environment}=this.parseEnvironment(props.env);if(this.account=account,this.region=region,this.environment=environment,this.terminationProtection=props.terminationProtection,props.description!==void 0){if(props.description.length>512)throw new Error(`Stack description must be <= 1024 bytes. Received description: '${props.description}'`);this.templateOptions.description=props.description}if(this._stackName=(_b=props.stackName)!==null&&_b!==void 0?_b:this.generateStackName(),this.tags=new tag_manager_1.TagManager(cfn_resource_1.TagType.KEY_VALUE,"aws:cdk:stack",props.tags),!VALID_STACK_NAME_REGEX.test(this.stackName))throw new Error(`Stack name must match the regular expression: ${VALID_STACK_NAME_REGEX.toString()}, got '${this.stackName}'`);const featureFlags=feature_flags_1.FeatureFlags.of(this),stackNameDupeContext=featureFlags.isEnabled(cxapi.ENABLE_STACK_NAME_DUPLICATES_CONTEXT),newStyleSynthesisContext=featureFlags.isEnabled(cxapi.NEW_STYLE_STACK_SYNTHESIS_CONTEXT);this.artifactId=stackNameDupeContext||newStyleSynthesisContext?this.generateStackArtifactId():this.stackName,this.templateFile=`${this.artifactId}.template.json`,this._versionReportingEnabled=((_c=props.analyticsReporting)!==null&&_c!==void 0?_c:this.node.tryGetContext(cxapi.ANALYTICS_REPORTING_ENABLED_CONTEXT))&&!this.nestedStackParent,this.synthesizer=(_d=props.synthesizer)!==null&&_d!==void 0?_d:newStyleSynthesisContext?new stack_synthesizers_1.DefaultStackSynthesizer:new stack_synthesizers_1.LegacyStackSynthesizer,this.synthesizer.bind(this)}static isStack(x){return x!==null&&typeof x=="object"&&STACK_SYMBOL in x}static of(construct){const cache=construct[MY_STACK_CACHE];if(cache)return cache;{const value=_lookup(construct);return Object.defineProperty(construct,MY_STACK_CACHE,{enumerable:!1,writable:!1,configurable:!1,value}),value}function _lookup(c){var _b,_c;if(Stack.isStack(c))return c;const _scope=constructs_1.Node.of(c).scope;if(stage_1.Stage.isStage(c)||!_scope)throw new Error(`${(_c=(_b=construct.constructor)===null||_b===void 0?void 0:_b.name)!==null&&_c!==void 0?_c:"Construct"} at '${constructs_1.Node.of(construct).path}' should be created in the scope of a Stack, but no Stack found`);return _lookup(_scope)}}resolve(obj){return resolve_1.resolve(obj,{scope:this,prefix:[],resolver:cloudformation_lang_1.CLOUDFORMATION_TOKEN_RESOLVER,preparing:!1})}toJsonString(obj,space){return cloudformation_lang_1.CloudFormationLang.toJSON(obj,space).toString()}reportMissingContext(report){if(!Object.values(cxschema.ContextProvider).includes(report.provider))throw new Error(`Unknown context provider requested in: ${JSON.stringify(report)}`);this.reportMissingContextKey(report)}reportMissingContextKey(report){jsiiDeprecationWarnings.aws_cdk_lib_cloud_assembly_schema_MissingContext(report),this._missingContext.push(report)}renameLogicalId(oldId,newId){this._logicalIds.addRename(oldId,newId)}getLogicalId(element){jsiiDeprecationWarnings.aws_cdk_lib_CfnElement(element);const logicalId=this.allocateLogicalId(element);return this._logicalIds.applyRename(logicalId)}addDependency(target,reason){jsiiDeprecationWarnings.aws_cdk_lib_Stack(target),deps_1.addDependency(this,target,reason)}get dependencies(){return Object.values(this._stackDependencies).map(x=>x.stack)}get stackName(){return this._stackName}get partition(){return cfn_pseudo_1.Aws.PARTITION}get urlSuffix(){return cfn_pseudo_1.Aws.URL_SUFFIX}get stackId(){return new cfn_pseudo_1.ScopedAws(this).stackId}get notificationArns(){return new cfn_pseudo_1.ScopedAws(this).notificationArns}get nested(){return this.nestedStackResource!==void 0}formatArn(components){return jsiiDeprecationWarnings.aws_cdk_lib_ArnComponents(components),arn_1.Arn.format(components,this)}parseArn(arn,sepIfToken="/",hasName=!0){return arn_1.Arn.parse(arn,sepIfToken,hasName)}splitArn(arn,arnFormat){return jsiiDeprecationWarnings.aws_cdk_lib_ArnFormat(arnFormat),arn_1.Arn.split(arn,arnFormat)}get availabilityZones(){if(token_1.Token.isUnresolved(this.account)||token_1.Token.isUnresolved(this.region))return this.node.tryGetContext(cxapi.AVAILABILITY_ZONE_FALLBACK_CONTEXT_KEY)||[cfn_fn_1.Fn.select(0,cfn_fn_1.Fn.getAzs()),cfn_fn_1.Fn.select(1,cfn_fn_1.Fn.getAzs())];const value=context_provider_1.ContextProvider.getValue(this,{provider:cxschema.ContextProvider.AVAILABILITY_ZONE_PROVIDER,dummyValue:["dummy1a","dummy1b","dummy1c"]}).value;if(!Array.isArray(value))throw new Error(`Provider ${cxschema.ContextProvider.AVAILABILITY_ZONE_PROVIDER} expects a list`);return value}addFileAsset(asset){return this.synthesizer.addFileAsset(asset)}addDockerImageAsset(asset){return this.synthesizer.addDockerImageAsset(asset)}get nestedStackParent(){return this.nestedStackResource&&Stack.of(this.nestedStackResource)}get parentStack(){return this.nestedStackParent}addTransform(transform){this.templateOptions.transforms||(this.templateOptions.transforms=[]),this.templateOptions.transforms.push(transform)}_addAssemblyDependency(target,reason){if(this.nested||target.nested)throw new Error("Cannot add assembly-level dependencies for nested stacks");reason=reason||"dependency added using stack.addDependency()";const cycle=target.stackDependencyReasons(this);if(cycle!==void 0)throw new Error(`'${target.node.path}' depends on '${this.node.path}' (${cycle.join(", ")}). Adding this dependency (${reason}) would create a cyclic reference.`);let dep=this._stackDependencies[names_1.Names.uniqueId(target)];dep||(dep=this._stackDependencies[names_1.Names.uniqueId(target)]={stack:target,reasons:[]}),dep.reasons.push(reason),process.env.CDK_DEBUG_DEPS&&console.error(`[CDK_DEBUG_DEPS] stack "${this.node.path}" depends on "${target.node.path}" because: ${reason}`)}_synthesizeTemplate(session,lookupRoleArn){const builder=session.assembly,template=this._toCloudFormation(),outPath=path.join(builder.outdir,this.templateFile);if(this.maxResources>0){const resources=template.Resources||{},numberOfResources=Object.keys(resources).length;if(numberOfResources>this.maxResources)throw new Error(`Number of resources in stack '${this.node.path}': ${numberOfResources} is greater than allowed maximum of ${this.maxResources}`);numberOfResources>=this.maxResources*.8&&annotations_1.Annotations.of(this).addInfo(`Number of resources: ${numberOfResources} is approaching allowed maximum of ${this.maxResources}`)}fs.writeFileSync(outPath,JSON.stringify(template,void 0,2));for(const ctx of this._missingContThere was an error synthesizing your app.
error Command failed with exit code 1.
info Visit <https://yarnpkg.com/en/docs/cli/run> for documentation about this command.
Seth Geoghegan
01/24/2022, 4:43 PMnode_modules
and yarn.lock
, reinstall packages via yarn
and executed yarn run start
This gives me the same result as aboveSeth Geoghegan
01/24/2022, 4:45 PM"dependencies": {
"@serverless-stack/cli": "0.60.4",
"@serverless-stack/resources": "0.60.4",
"aws-cdk-lib": "2.7.0"
},
Seth Geoghegan
01/24/2022, 5:21 PMcdk.context.json
file and tried yarn run start
This seems to have done the trick. I guess that file ended up in a weird stateFrank
Frank
Frank
cdk.context.json
and I will try to reproduce this on my end.Seth Geoghegan
01/25/2022, 2:02 PMcdk.context.json
before deleting and re-building, but it was my last guess. Smooth sailing since, but I'll make sure to DM the file if I get into this state again.Seth Geoghegan
01/25/2022, 9:36 PMFrank
package.json
😁Seth Geoghegan
01/26/2022, 12:53 PM"scripts": {
"start": "sst start --stage ${whoami}"
...
}
${whoami}
is not correct, but $(whoami)
is.