Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(type-safe-api): create a new asset with PrepareApiSpecOptions props and used it in PrepareApiSpecCustomResourceProperties instead or raw properties in order to avoid large payload that can cause the PrepareSpecCustomResource to fail #773

Conversation

valebedu
Copy link
Contributor

Fixes #771

…ps and used it in PrepareApiSpecCustomResourceProperties instead or raw properties in order to avoid large payload that can cause the PrepareSpecCustomResource to fail
@valebedu
Copy link
Contributor Author

valebedu commented Apr 24, 2024

Hi @agdimech,

Here is a pull request, I don't have any more time at the moment to work on it, I will test it tonight (in ~12h in my time zone)

I just pushed it if you want to take a look

@agdimech
Copy link
Contributor

agdimech commented May 8, 2024

Sorry for the delay - just wanted to check in to see whether this is ready for review and has this been tested?

@valebedu
Copy link
Contributor Author

valebedu commented May 8, 2024

I just tried but I got an error now when I run pdk build project on the generate-license-file step. This is the first time I got this error, I tried to clean deps, reset nx cache but the error persist. Do you have any idea of the issue?

@aws/pdk: 👾 build » package | pnpm exec generate-license-file --input package.json --output LICENSE_THIRD_PARTY --overwrite
@aws/pdk: /Users/vale/Workspace/lab/aws-pdk/node_modules/.pnpm/esm@3.2.25/node_modules/esm/esm.js:1
@aws/pdk: const __global__ = this;(function (require, module, __shared__) { var __shared__;const e=module,t={Array:global.Array,Buffer:global.Buffer,Error:global.Error,EvalError:global.EvalError,Function:global.Function,JSON:global.JSON,Object:global.Object,Promise:global.Promise,RangeError:global.RangeError,ReferenceError:global.ReferenceError,Reflect:global.Reflect,SyntaxError:global.SyntaxError,TypeError:global.TypeError,URIError:global.URIError,eval:global.eval},r=global.console;module.exports=(function(e){var t={};function r(i){if(t[i])return t[i].exports;var n=t[i]={i:i,l:!1,exports:{}};return e[i].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.d=function(e,t,r){Reflect.defineProperty(e,t,{configurable:!0,enumerable:!0,get:r})},r.n=function(e){return e.a=e,function(){return e}},r(r.s=2)})([(function(e,t){var r;t=e.exports=$,"object"==typeof process&&process,r=function(){},t.SEMVER_SPEC_VERSION="2.0.0";var i=256,n=Number.MAX_SAFE_INTEGER||9007199254740991,s=t.re=[],a=t.src=[],o=0,u=o++;a[u]="0|[1-9]\\d*";var l=o++;a[l]="[0-9]+";var c=o++;a[c]="\\d*[a-zA-Z-][a-zA-Z0-9-]*";var p=o++;a[p]="("+a[u]+")\\.("+a[u]+")\\.("+a[u]+")";var h=o++;a[h]="("+a[l]+")\\.("+a[l]+")\\.("+a[l]+")";var f=o++;a[f]="(?:"+a[u]+"|"+a[c]+")";var d=o++;a[d]="(?:"+a[l]+"|"+a[c]+")";var m=o++;a[m]="(?:-("+a[f]+"(?:\\."+a[f]+")*))";var v=o++;a[v]="(?:-?("+a[d]+"(?:\\."+a[d]+")*))";var g=o++;a[g]="[0-9A-Za-z-]+";var y=o++;a[y]="(?:\\+("+a[g]+"(?:\\."+a[g]+")*))";var x=o++,b="v?"+a[p]+a[m]+"?"+a[y]+"?";a[x]="^"+b+"$";var w="[v=\\s]*"+a[h]+a[v]+"?"+a[y]+"?",E=o++;a[E]="^"+w+"$";var S=o++;a[S]="((?:<|>)?=?)";var R=o++;a[R]=a[l]+"|x|X|\\*";var P=o++;a[P]=a[u]+"|x|X|\\*";var _=o++;a[_]="[v=\\s]*("+a[P]+")(?:\\.("+a[P]+")(?:\\.("+a[P]+")(?:"+a[m]+")?"+a[y]+"?)?)?";var k=o++;a[k]="[v=\\s]*("+a[R]+")(?:\\.("+a[R]+")(?:\\.("+a[R]+")(?:"+a[v]+")?"+a[y]+"?)?)?";var I=o++;a[I]="^"+a[S]+"\\s*"+a[_]+"$";var A=o++;a[A]="^"+a[S]+"\\s*"+a[k]+"$";var N=o++;a[N]="(?:^|[^\\d])(\\d{1,16})(?:\\.(\\d{1,16}))?(?:\\.(\\d{1,16}))?(?:$|[^\\d])";var C=o++;a[C]="(?:~>?)";var O=o++;a[O]="(\\s*)"+a[C]+"\\s+",s[O]=RegExp(a[O],"g");var T=o++;a[T]="^"+a[C]+a[_]+"$";var M=o++;a[M]="^"+a[C]+a[k]+"$";var L=o++;a[L]="(?:\\^)";var D=o++;a[D]="(\\s*)"+a[L]+"\\s+",s[D]=RegExp(a[D],"g");var F=o++;a[F]="^"+a[L]+a[_]+"$";var j=o++;a[j]="^"+a[L]+a[k]+"$";var V=o++;a[V]="^"+a[S]+"\\s*("+w+")$|^$";var G=o++;a[G]="^"+a[S]+"\\s*("+b+")$|^$";var B=o++;a[B]="(\\s*)"+a[S]+"\\s*("+w+"|"+a[_]+")",s[B]=RegExp(a[B],"g");var U=o++;a[U]="^\\s*("+a[_]+")\\s+-\\s+("+a[_]+")\\s*$";var W=o++;a[W]="^\\s*("+a[k]+")\\s+-\\s+("+a[k]+")\\s*$";var q=o++;a[q]="(<|>)?=?\\s*\\*";for(var z=0;z<35;z++)r(z,a[z]),s[z]||(s[z]=RegExp(a[z]));function H(e,t){"use strict";if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof $)return e;if("string"!=typeof e)return null;if(e.length>i)return null;var r=t.loose?s[E]:s[x];if(!r.test(e))return null;try{return new $(e,t)}catch(e){return null}}function $(e,t){"use strict";if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof $){if(e.loose===t.loose)return e;e=e.version}else if("string"!=typeof e)throw new TypeError("Invalid Version: "+e);if(e.length>i)throw new TypeError("version is longer than "+i+" characters");if(!(this instanceof $))return new $(e,t);r("SemVer",e,t),this.options=t,this.loose=!!t.loose;var a=e.trim().match(t.loose?s[E]:s[x]);if(!a)throw new TypeError("Invalid Version: "+e);if(this.raw=e,this.major=+a[1],this.minor=+a[2],this.patch=+a[3],this.major>n||this.major<0)throw new TypeError("Invalid major version");if(this.minor>n||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>n||this.patch<0)throw new TypeError("Invalid patch version");this.prerelease=a[4]?a[4].split(".").map((function(e){if(/^[0-9]+$/.test(e)){var t=+e;if(t>=0&&t<n)return t}return e})):[],this.build=a[5]?a[5].split("."):[],this.format()}t.parse=H,t.valid=function(e,t){"use strict";var r=H(e,t);return r?r.version:null},t.clean=function(e,t){"use strict";var r=H(e.trim().replace(/^[=v]+/,""),t);return r?r.version:null},t.SemVer=$,$.prototype.format=function(){"use strict";return this.version=this.major+"."+this.minor+"."+this.patch,this.prerelease.length&&(this.version+="-"+this.prerelease.join(".")),this.version},$.prototype.toString=function(){"use strict";return this.version},$.prototype.compare=function(e){"use strict";return r("SemVer.compare",this.version,this.options,e),e instanceof $||(e=new $(e,this.options)),this.compareMain(e)||this.comparePre(e)},$.prototype.compareMain=function(e){"use strict";return e instanceof $||(e=new $(e,this.options)),J(this.major,e.major)||J(this.minor,e.minor)||J(this.patch,e.patch)},$.prototype.comparePre=function(e){"use strict";if(e instanceof $||(e=new $(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;var t=0;do{var i=this.prerelease[t],n=e.prerelease[t];if(r("prerelease compare",t,i,n),void 0===i&&void 0===n)return 0;if(void 0===n)return 1;if(void 0===i)return-1;if(i!==n)return J(i,n)}while(++t)},$.prototype.inc=function(e,t){"use strict";switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",t);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t);break;case"prepatch":this.prerelease.length=0,this.inc("patch",t),this.inc("pre",t);break;case"prerelease":0===this.prerelease.length&&this.inc("patch",t),this.inc("pre",t);break;case"major":0===this.minor&&0===this.patch&&0!==this.prerelease.length||this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":0===this.patch&&0!==this.prerelease.length||this.minor++,this.patch=0,this.prerelease=[];break;case"patch":0===this.prerelease.length&&this.patch++,this.prerelease=[];break;case"pre":if(0===this.prerelease.length)this.prerelease=[0];else{for(var r=this.prerelease.length;--r>=0;)"number"==typeof this.prerelease[r]&&(this.prerelease[r]++,r=-2);-1===r&&this.prerelease.push(0)}t&&(this.prerelease[0]===t?isNaN(this.prerelease[1])&&(this.prerelease=[t,0]):this.prerelease=[t,0]);break;default:throw Error("invalid increment argument: "+e)}return this.format(),this.raw=this.version,this},t.inc=function(e,t,r,i){"use strict";"string"==typeof r&&(i=r,r=void 0);try{return new $(e,r).inc(t,i).version}catch(e){return null}},t.diff=function(e,t){"use strict";if(Z(e,t))return null;var r=H(e),i=H(t),n="";if(r.prerelease.length||i.prerelease.length){n="pre";var s="prerelease"}for(var a in r)if(("major"===a||"minor"===a||"patch"===a)&&r[a]!==i[a])return n+a;return s},t.compareIdentifiers=J;var K=/^[0-9]+$/;function J(e,t){"use strict";var r=K.test(e),i=K.test(t);return r&&i&&(e=+e,t=+t),e===t?0:r&&!i?-1:i&&!r?1:e<t?-1:1}function Y(e,t,r){"use strict";return new $(e,r).compare(new $(t,r))}function X(e,t,r){"use strict";return Y(e,t,r)>0}function Q(e,t,r){"use strict";return Y(e,t,r)<0}function Z(e,t,r){"use strict";return 0===Y(e,t,r)}function ee(e,t,r){"use strict";return 0!==Y(e,t,r)}function te(e,t,r){"use strict";return Y(e,t,r)>=0}function re(e,t,r){"use strict";return Y(e,t,r)<=0}function ie(e,t,r,i){"use strict";switch(t){case"===":return"object"==typeof e&&(e=e.version),"object"==typeof r&&(r=r.version),e===r;case"!==":return"object"==typeof e&&(e=e.version),"object"==typeof r&&(r=r.version),e!==r;case"":case"=":case"==":return Z(e,r,i);case"!=":return ee(e,r,i);case">":return X(e,r,i);case">=":return te(e,r,i);case"<":return Q(e,r,i);case"<=":return re(e,r,i);default:throw new TypeError("Invalid operator: "+t)}}function ne(e,t){"use strict";if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof ne){if(e.loose===!!t.loose)return e;e=e.value}if(!(this instanceof ne))return new ne(e,t);r("comparator",e,t),this.options=t,this.loose=!!t.loose,this.parse(e),this.value=this.semver===se?"":this.operator+this.semver.version,r("comp",this)}t.rcompareIdentifiers=function(e,t){"use strict";return J(t,e)},t.major=function(e,t){"use strict";
@aws/pdk: Node.js v22.1.0
@aws/pdk: 👾 Task "build » package" failed when executing "pnpm exec generate-license-file --input package.json --output LICENSE_THIRD_PARTY --overwrite" (cwd: /Users/vale/Workspace/lab/aws-pdk/packages/pdk)
@aws/pdk: Warning: run-commands command "pnpm exec projen build" exited with non-zero status code

@agdimech
Copy link
Contributor

agdimech commented May 8, 2024

I just tried but I got an error now when I run pdk build project on the generate-license-file step. This is the first time I got this error, I tried to clean deps, reset nx cache but the error persist. Do you have any idea of the issue?

@aws/pdk: 👾 build » package | pnpm exec generate-license-file --input package.json --output LICENSE_THIRD_PARTY --overwrite
@aws/pdk: /Users/vale/Workspace/lab/aws-pdk/node_modules/.pnpm/esm@3.2.25/node_modules/esm/esm.js:1
@aws/pdk: const __global__ = this;(function (require, module, __shared__) { var __shared__;const e=module,t={Array:global.Array,Buffer:global.Buffer,Error:global.Error,EvalError:global.EvalError,Function:global.Function,JSON:global.JSON,Object:global.Object,Promise:global.Promise,RangeError:global.RangeError,ReferenceError:global.ReferenceError,Reflect:global.Reflect,SyntaxError:global.SyntaxError,TypeError:global.TypeError,URIError:global.URIError,eval:global.eval},r=global.console;module.exports=(function(e){var t={};function r(i){if(t[i])return t[i].exports;var n=t[i]={i:i,l:!1,exports:{}};return e[i].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.d=function(e,t,r){Reflect.defineProperty(e,t,{configurable:!0,enumerable:!0,get:r})},r.n=function(e){return e.a=e,function(){return e}},r(r.s=2)})([(function(e,t){var r;t=e.exports=$,"object"==typeof process&&process,r=function(){},t.SEMVER_SPEC_VERSION="2.0.0";var i=256,n=Number.MAX_SAFE_INTEGER||9007199254740991,s=t.re=[],a=t.src=[],o=0,u=o++;a[u]="0|[1-9]\\d*";var l=o++;a[l]="[0-9]+";var c=o++;a[c]="\\d*[a-zA-Z-][a-zA-Z0-9-]*";var p=o++;a[p]="("+a[u]+")\\.("+a[u]+")\\.("+a[u]+")";var h=o++;a[h]="("+a[l]+")\\.("+a[l]+")\\.("+a[l]+")";var f=o++;a[f]="(?:"+a[u]+"|"+a[c]+")";var d=o++;a[d]="(?:"+a[l]+"|"+a[c]+")";var m=o++;a[m]="(?:-("+a[f]+"(?:\\."+a[f]+")*))";var v=o++;a[v]="(?:-?("+a[d]+"(?:\\."+a[d]+")*))";var g=o++;a[g]="[0-9A-Za-z-]+";var y=o++;a[y]="(?:\\+("+a[g]+"(?:\\."+a[g]+")*))";var x=o++,b="v?"+a[p]+a[m]+"?"+a[y]+"?";a[x]="^"+b+"$";var w="[v=\\s]*"+a[h]+a[v]+"?"+a[y]+"?",E=o++;a[E]="^"+w+"$";var S=o++;a[S]="((?:<|>)?=?)";var R=o++;a[R]=a[l]+"|x|X|\\*";var P=o++;a[P]=a[u]+"|x|X|\\*";var _=o++;a[_]="[v=\\s]*("+a[P]+")(?:\\.("+a[P]+")(?:\\.("+a[P]+")(?:"+a[m]+")?"+a[y]+"?)?)?";var k=o++;a[k]="[v=\\s]*("+a[R]+")(?:\\.("+a[R]+")(?:\\.("+a[R]+")(?:"+a[v]+")?"+a[y]+"?)?)?";var I=o++;a[I]="^"+a[S]+"\\s*"+a[_]+"$";var A=o++;a[A]="^"+a[S]+"\\s*"+a[k]+"$";var N=o++;a[N]="(?:^|[^\\d])(\\d{1,16})(?:\\.(\\d{1,16}))?(?:\\.(\\d{1,16}))?(?:$|[^\\d])";var C=o++;a[C]="(?:~>?)";var O=o++;a[O]="(\\s*)"+a[C]+"\\s+",s[O]=RegExp(a[O],"g");var T=o++;a[T]="^"+a[C]+a[_]+"$";var M=o++;a[M]="^"+a[C]+a[k]+"$";var L=o++;a[L]="(?:\\^)";var D=o++;a[D]="(\\s*)"+a[L]+"\\s+",s[D]=RegExp(a[D],"g");var F=o++;a[F]="^"+a[L]+a[_]+"$";var j=o++;a[j]="^"+a[L]+a[k]+"$";var V=o++;a[V]="^"+a[S]+"\\s*("+w+")$|^$";var G=o++;a[G]="^"+a[S]+"\\s*("+b+")$|^$";var B=o++;a[B]="(\\s*)"+a[S]+"\\s*("+w+"|"+a[_]+")",s[B]=RegExp(a[B],"g");var U=o++;a[U]="^\\s*("+a[_]+")\\s+-\\s+("+a[_]+")\\s*$";var W=o++;a[W]="^\\s*("+a[k]+")\\s+-\\s+("+a[k]+")\\s*$";var q=o++;a[q]="(<|>)?=?\\s*\\*";for(var z=0;z<35;z++)r(z,a[z]),s[z]||(s[z]=RegExp(a[z]));function H(e,t){"use strict";if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof $)return e;if("string"!=typeof e)return null;if(e.length>i)return null;var r=t.loose?s[E]:s[x];if(!r.test(e))return null;try{return new $(e,t)}catch(e){return null}}function $(e,t){"use strict";if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof $){if(e.loose===t.loose)return e;e=e.version}else if("string"!=typeof e)throw new TypeError("Invalid Version: "+e);if(e.length>i)throw new TypeError("version is longer than "+i+" characters");if(!(this instanceof $))return new $(e,t);r("SemVer",e,t),this.options=t,this.loose=!!t.loose;var a=e.trim().match(t.loose?s[E]:s[x]);if(!a)throw new TypeError("Invalid Version: "+e);if(this.raw=e,this.major=+a[1],this.minor=+a[2],this.patch=+a[3],this.major>n||this.major<0)throw new TypeError("Invalid major version");if(this.minor>n||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>n||this.patch<0)throw new TypeError("Invalid patch version");this.prerelease=a[4]?a[4].split(".").map((function(e){if(/^[0-9]+$/.test(e)){var t=+e;if(t>=0&&t<n)return t}return e})):[],this.build=a[5]?a[5].split("."):[],this.format()}t.parse=H,t.valid=function(e,t){"use strict";var r=H(e,t);return r?r.version:null},t.clean=function(e,t){"use strict";var r=H(e.trim().replace(/^[=v]+/,""),t);return r?r.version:null},t.SemVer=$,$.prototype.format=function(){"use strict";return this.version=this.major+"."+this.minor+"."+this.patch,this.prerelease.length&&(this.version+="-"+this.prerelease.join(".")),this.version},$.prototype.toString=function(){"use strict";return this.version},$.prototype.compare=function(e){"use strict";return r("SemVer.compare",this.version,this.options,e),e instanceof $||(e=new $(e,this.options)),this.compareMain(e)||this.comparePre(e)},$.prototype.compareMain=function(e){"use strict";return e instanceof $||(e=new $(e,this.options)),J(this.major,e.major)||J(this.minor,e.minor)||J(this.patch,e.patch)},$.prototype.comparePre=function(e){"use strict";if(e instanceof $||(e=new $(e,this.options)),this.prerelease.length&&!e.prerelease.length)return-1;if(!this.prerelease.length&&e.prerelease.length)return 1;if(!this.prerelease.length&&!e.prerelease.length)return 0;var t=0;do{var i=this.prerelease[t],n=e.prerelease[t];if(r("prerelease compare",t,i,n),void 0===i&&void 0===n)return 0;if(void 0===n)return 1;if(void 0===i)return-1;if(i!==n)return J(i,n)}while(++t)},$.prototype.inc=function(e,t){"use strict";switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",t);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t);break;case"prepatch":this.prerelease.length=0,this.inc("patch",t),this.inc("pre",t);break;case"prerelease":0===this.prerelease.length&&this.inc("patch",t),this.inc("pre",t);break;case"major":0===this.minor&&0===this.patch&&0!==this.prerelease.length||this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":0===this.patch&&0!==this.prerelease.length||this.minor++,this.patch=0,this.prerelease=[];break;case"patch":0===this.prerelease.length&&this.patch++,this.prerelease=[];break;case"pre":if(0===this.prerelease.length)this.prerelease=[0];else{for(var r=this.prerelease.length;--r>=0;)"number"==typeof this.prerelease[r]&&(this.prerelease[r]++,r=-2);-1===r&&this.prerelease.push(0)}t&&(this.prerelease[0]===t?isNaN(this.prerelease[1])&&(this.prerelease=[t,0]):this.prerelease=[t,0]);break;default:throw Error("invalid increment argument: "+e)}return this.format(),this.raw=this.version,this},t.inc=function(e,t,r,i){"use strict";"string"==typeof r&&(i=r,r=void 0);try{return new $(e,r).inc(t,i).version}catch(e){return null}},t.diff=function(e,t){"use strict";if(Z(e,t))return null;var r=H(e),i=H(t),n="";if(r.prerelease.length||i.prerelease.length){n="pre";var s="prerelease"}for(var a in r)if(("major"===a||"minor"===a||"patch"===a)&&r[a]!==i[a])return n+a;return s},t.compareIdentifiers=J;var K=/^[0-9]+$/;function J(e,t){"use strict";var r=K.test(e),i=K.test(t);return r&&i&&(e=+e,t=+t),e===t?0:r&&!i?-1:i&&!r?1:e<t?-1:1}function Y(e,t,r){"use strict";return new $(e,r).compare(new $(t,r))}function X(e,t,r){"use strict";return Y(e,t,r)>0}function Q(e,t,r){"use strict";return Y(e,t,r)<0}function Z(e,t,r){"use strict";return 0===Y(e,t,r)}function ee(e,t,r){"use strict";return 0!==Y(e,t,r)}function te(e,t,r){"use strict";return Y(e,t,r)>=0}function re(e,t,r){"use strict";return Y(e,t,r)<=0}function ie(e,t,r,i){"use strict";switch(t){case"===":return"object"==typeof e&&(e=e.version),"object"==typeof r&&(r=r.version),e===r;case"!==":return"object"==typeof e&&(e=e.version),"object"==typeof r&&(r=r.version),e!==r;case"":case"=":case"==":return Z(e,r,i);case"!=":return ee(e,r,i);case">":return X(e,r,i);case">=":return te(e,r,i);case"<":return Q(e,r,i);case"<=":return re(e,r,i);default:throw new TypeError("Invalid operator: "+t)}}function ne(e,t){"use strict";if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof ne){if(e.loose===!!t.loose)return e;e=e.value}if(!(this instanceof ne))return new ne(e,t);r("comparator",e,t),this.options=t,this.loose=!!t.loose,this.parse(e),this.value=this.semver===se?"":this.operator+this.semver.version,r("comp",this)}t.rcompareIdentifiers=function(e,t){"use strict";return J(t,e)},t.major=function(e,t){"use strict";
@aws/pdk: Node.js v22.1.0
@aws/pdk: 👾 Task "build » package" failed when executing "pnpm exec generate-license-file --input package.json --output LICENSE_THIRD_PARTY --overwrite" (cwd: /Users/vale/Workspace/lab/aws-pdk/packages/pdk)
@aws/pdk: Warning: run-commands command "pnpm exec projen build" exited with non-zero status code

Can you try downgrading your Node version to 18?

@valebedu
Copy link
Contributor Author

Thanks, I downgraded my version to node@20 and will stay on that version from now. It now builds as expected.

I followed the official documentation in order to use my local package and tried it with a production use case in a sandbox environment.

By looking at assets in S3, we now have a new input-config.json asset generated that corresponds to all the prepareSpecOptions.

The previous error related to the prepare spec resource has now been resolved.

Previously, there was an error with the ApiPrepareSpecCustomResourceAF67685F resource:

364763 byte payload is too large for the Event invocation type (limit 262144 bytes) (Service: AWSLambda; Status Code: 413; Error Code: RequestEntityTooLargeException; Request ID: 88eac928-edb4-4a6e-ad0a-dd73ab3cb230; Proxy: null)

However, I now have encountered a new error in the API.

The new error on ApiCD79AAA0 is:

Resource handler returned message: "Invalid ARN specified in the request (Service: ApiGateway, Status Code: 400, Request ID: 807dc08e-01fc-498c-a48d-7201e6983415)" (RequestToken: 56010696-6f1d-466b-7a91-ad55f19ef843, HandlerErrorCode: InvalidRequest)

So, I tried to find differences between the output prepared spec and discovered that tokens weren't resolved. Indeed, by looking at the input-config.json asset, I found occurrences of the following throughout the file:

"getCompanies": {
    "integration": {
        "type": "AWS_PROXY",
        "httpMethod": "POST",
        "uri": "arn:aws:apigateway:eu-west-1:lambda:path/2015-03-31/functions/${Token[TOKEN.2257]}/invocations",
        "passthroughBehavior": "WHEN_NO_MATCH"
    },
    "methodAuthorizer": {
        "authorizerId": "cognito-authorizer",
        "authorizationScopes": [
            "${Token[TOKEN.2208]}/companies.read"
        ]
    }
},

I think that synchronously write the prepareSpecOptions is not the right way to achieve this

https://github.com/aws/aws-pdk/pull/773/files#diff-534717be774b2482f863f0aa14fd205eea414941b9f72300594e1adb58d40267R172-R193

@valebedu
Copy link
Contributor Author

Hi @agdimech,

I hope you're doing well. I wanted to follow up on my previous comment. I've been diving into the issue and think I might've stumbled upon a workaround for token resolution at deploy-time.

I've looked into the official AWS CDK documentation regarding S3 Deployment and it appears that S3 Deployment supports deploy-time values, which could be a good solution for our use case.

I'm thinking we could tweak our approach a bit and play around with the deployment structure. Something like this perhaps:

${timestamp}/
|_ input-spec.json
|_ input-config.json
|_ output-spec.json

and create a new PrepareSpecBucket responsible for holding these files.

This could help keep things neat and tidy. Before I dive deeper into this, I'd love to hear your take on it. Let me know if you think it aligns with what we're aiming for or if you have any other solution that keep current asset in default CDK asset bucket.

@agdimech
Copy link
Contributor

agdimech commented May 23, 2024

Hi @valebedu,

The BucketDeployment definitely looks like the way to go! I wasn't entirely sure about what the timestamp represented above (perhaps asset deployment instance?) although I am wandering, could we re-use the Asset bucket and do something like this instead?

new s3deploy.BucketDeployment(this, 'OptionsDeployment', {
  sources: [s3deploy.Source.jsonData(`preparedSpecOptions.json`, prepareSpecOptions)],
  destinationBucket: inputSpecAsset.bucket,
  destinationKeyPrefix: `${inputSpecAsset.s3ObjectKey}-options`
});

@valebedu
Copy link
Contributor Author

Yes it's simpler to do that, it was just a proposition to move assets to separate buckets and to support history with a timestamp or datetime as a root folder.

I've pushed changes and try to build but I got an error everytime time.

I'm using node@20 and pnpm@8, I clean deps and really don't understand why I got an issue about deployment and didn't find any related issue on github. Any idea?

...
@aws/docs: WARNING  -  Documentation file 'api/python/monorepo/index.md' contains a link to 'api/python/monorepo/{@link TaskStepOptions.receiveArgs }' which is not found in the documentation files.
@aws/pdk: Error: Command (rm -rf build && pnpm --config.shamefully-hoist=true --config.hoist=true --config.symlinks=false --config.shared-workspace-lockfile=false --filter=@aws/pdk deploy build && cd build && pnpm pack && mv *.tgz .. && cd .. && rm -rf build ) failed with status 1:
@aws/pdk: #STDERR> 
@aws/pdk: #STDOUT>  ERR_PNPM_CANNOT_DEPLOY_MANY  Cannot deploy more than 1 project
@aws/pdk: #STDOUT> 
@aws/pdk:     at ChildProcess.<anonymous> (/Users/vale/Workspace/lab/aws-pdk/node_modules/.pnpm/jsii-pacmak@1.91.0/node_modules/jsii-pacmak/lib/util.js:175:27)
@aws/pdk:     at Object.onceWrapper (node:events:634:26)
@aws/pdk:     at ChildProcess.emit (node:events:519:28)
@aws/pdk:     at maybeClose (node:internal/child_process:1105:16)
@aws/pdk:     at Socket.<anonymous> (node:internal/child_process:457:11)
@aws/pdk:     at Socket.emit (node:events:519:28)
@aws/pdk:     at Pipe.<anonymous> (node:net:338:12)
@aws/pdk: 👾 Task "build » package » package-all » package:js" failed when executing "jsii-pacmak -v --target js --pack-command='rm -rf build && pnpm --config.shamefully-hoist=true --config.hoist=true --config.symlinks=false --config.shared-workspace-lockfile=false --filter=@aws/pdk deploy build && cd build && pnpm pack && mv *.tgz .. && cd .. && rm -rf build'" (cwd: /Users/vale/Workspace/lab/aws-pdk/packages/pdk)
@aws/pdk: Warning: run-commands command "pnpm exec projen build" exited with non-zero status code
@aws/docs: WARNING  -  Documentation file 'api/python/type-safe-api/index.md' contains a link to 'api/python/type-safe-api/Permission for details.' which is not found in the documentation files.
...

@agdimech
Copy link
Contributor

Yes it's simpler to do that, it was just a proposition to move assets to separate buckets and to support history with a timestamp or datetime as a root folder.

I've pushed changes and try to build but I got an error everytime time.

I'm using node@20 and pnpm@8, I clean deps and really don't understand why I got an issue about deployment and didn't find any related issue on github. Any idea?

...
@aws/docs: WARNING  -  Documentation file 'api/python/monorepo/index.md' contains a link to 'api/python/monorepo/{@link TaskStepOptions.receiveArgs }' which is not found in the documentation files.
@aws/pdk: Error: Command (rm -rf build && pnpm --config.shamefully-hoist=true --config.hoist=true --config.symlinks=false --config.shared-workspace-lockfile=false --filter=@aws/pdk deploy build && cd build && pnpm pack && mv *.tgz .. && cd .. && rm -rf build ) failed with status 1:
@aws/pdk: #STDERR> 
@aws/pdk: #STDOUT>  ERR_PNPM_CANNOT_DEPLOY_MANY  Cannot deploy more than 1 project
@aws/pdk: #STDOUT> 
@aws/pdk:     at ChildProcess.<anonymous> (/Users/vale/Workspace/lab/aws-pdk/node_modules/.pnpm/jsii-pacmak@1.91.0/node_modules/jsii-pacmak/lib/util.js:175:27)
@aws/pdk:     at Object.onceWrapper (node:events:634:26)
@aws/pdk:     at ChildProcess.emit (node:events:519:28)
@aws/pdk:     at maybeClose (node:internal/child_process:1105:16)
@aws/pdk:     at Socket.<anonymous> (node:internal/child_process:457:11)
@aws/pdk:     at Socket.emit (node:events:519:28)
@aws/pdk:     at Pipe.<anonymous> (node:net:338:12)
@aws/pdk: 👾 Task "build » package » package-all » package:js" failed when executing "jsii-pacmak -v --target js --pack-command='rm -rf build && pnpm --config.shamefully-hoist=true --config.hoist=true --config.symlinks=false --config.shared-workspace-lockfile=false --filter=@aws/pdk deploy build && cd build && pnpm pack && mv *.tgz .. && cd .. && rm -rf build'" (cwd: /Users/vale/Workspace/lab/aws-pdk/packages/pdk)
@aws/pdk: Warning: run-commands command "pnpm exec projen build" exited with non-zero status code
@aws/docs: WARNING  -  Documentation file 'api/python/type-safe-api/index.md' contains a link to 'api/python/type-safe-api/Permission for details.' which is not found in the documentation files.
...

Hmm i'm not too sure - I triggered a build via CI and it all built successfully. Try deleting the packages/pdk/build and packages/pdk/dist folders.

In order to instanciate bucket deployment before prepare spec custom resource
@valebedu
Copy link
Contributor Author

I attempted with some changes, but now I encounter the same error with ApiOptionsDeploymentCustomResource859991B0:

652317 byte payload is too large for the Event invocation type (limit 262144 bytes) (Service: AWSLambda; Status Code: 413; Error Code: RequestEntityTooLargeException; Request ID: fbda881d-8c10-4a41-b189-c96c1cad63f7; Proxy: null)

Adding a bucket deployment with deploy-time values merely shifts the problem to the bucket deployment.

It appears there is no effective solution for this issue at the moment. 😞

This suggests a virtual limit to the API Gateway size due to the Lambda payload limit, which constrains how large the API can be.

@agdimech
Copy link
Contributor

Hi @valebedu ,

I had a chat with @cogwirrel on Friday and we may have found a solution (potentially).

1.) We could use a Trigger, instead of a custom resource to write the options into an S3 Bucket. The Trigger is able to call a Lamda at deployment time using a standard Request/Response interaction which allows for a 6Mb payload (128kb is max using custom resource). We could then pass the reference to the S3 bucket into the PrepareSpecHandler like we do in the other places.
2.) Ensure the Trigger is depended upon by the PrepareSpecHandler to ensure the S3 Bucket is written before it is called.
3.) For every deployment, we would simply invoke the trigger to write the new options (no need to manage Create/Update/Delete state).

@valebedu
Copy link
Contributor Author

valebedu commented Jun 11, 2024

Hi @agdimech,

Awesome! Because it's a sync lambda it as a payload limit to 6MB right? this is really good, I didn't understand why custom resource is made like this because the payload limit in async func can be a problem in some scenarios.

So we can add a trigger to execute synchronously a lambda function perfect, but which function to call? we need a function similar to the one used in custom resource that resolve deploy time values, any idea on this one?

@agdimech
Copy link
Contributor

agdimech commented Jun 13, 2024

Hi @valebedu,

Yes, 6Mb will be the payload size which means an increase of ~50x larger payloads :)

I'm pretty sure if you pass in the values to the lambda, cloudformation should handle the substitution for you?

@valebedu
Copy link
Contributor Author

CloudFormation can indeed resolve !Ref !GetAtt etc, but it can't resolve ${Token} like in the following

"getCompanies": {
    "integration": {
        "type": "AWS_PROXY",
        "httpMethod": "POST",
        "uri": "arn:aws:apigateway:eu-west-1:lambda:path/2015-03-31/functions/${Token[TOKEN.2257]}/invocations",
        "passthroughBehavior": "WHEN_NO_MATCH"
    },
    "methodAuthorizer": {
        "authorizerId": "cognito-authorizer",
        "authorizationScopes": [
            "${Token[TOKEN.2208]}/companies.read"
        ]
    }
},

That's why S3 deployment seams the right solution because it's specified in the documentation that deploy-time values are supported

I think that to improve the process we should use a lambda similar to the one used in s3 deployment but synchronlously in order to raise lambda payload limit to 6MB but don't know hom. Maybe I should make a FR to aws-cdk ?

@agdimech
Copy link
Contributor

How are you setting up the Trigger? I haven't use it before but based on the docs you should be able to do something like:

https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.triggers.Trigger.html#executeafter

Then just set up all the deps in their and hopefully the Tokens should get resolved.

@valebedu
Copy link
Contributor Author

I'm sorry but I have really no idea of how to replace Provider and CustomResource with a Trigger.

I never used it, there is no way to define the input (spec location and prepare spec options) and no way to retrieve the output key

@agdimech
Copy link
Contributor

agdimech commented Jun 17, 2024

So I did some more digging and you can actually configure a CustomResource to invoke the underlying lambda via an InvocationType property as per: https://docs.aws.amazon.com/lambda/latest/api/API_Invoke.html. This is actually what the Trigger is doing in it's implementation. Can you try updating the CustomResource to add the InvocationType like the following snippet:

const prepareSpecCustomResource = new CustomResource(
  this,
  "PrepareSpecCustomResource",
  {
    serviceToken: provider.serviceToken,
    properties: {
      ...prepareApiSpecCustomResourceProperties,
      InvocationType:'RequestResponse'
   },
  }
);

Copy link

nx-cloud bot commented Jun 27, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 3c20cf4. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

Copy link

This pull request is now marked as stale because it hasn't seen activity for a while. Add a comment or it will be closed soon. If you wish to exclude this issue from being marked as stale, add the "backlog" label.

@github-actions github-actions bot added the stale label Jul 15, 2024
Copy link

Closing this pull request as it hasn't seen activity for a while. Please add a comment @mentioning a maintainer to reopen. If you wish to exclude this issue from being marked as stale, add the "backlog" label.

@github-actions github-actions bot closed this Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] (type-safe-api) PrepareSpecCustomResource fail with error 413 in large API with many integrations
2 participants