@pulumi-helpers/component-alicloud-fc3
Version:
1 lines • 4.57 kB
JavaScript
;var componentAlicloudLog=require('@pulumi-helpers/component-alicloud-log'),componentAlicloudRamUser=require('@pulumi-helpers/component-alicloud-ram-user'),componentRandomSuffix=require('@pulumi-helpers/component-random-suffix'),o=require('@pulumi/alicloud'),c=require('@pulumi/pulumi');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var o__namespace=/*#__PURE__*/_interopNamespace(o);var c__namespace=/*#__PURE__*/_interopNamespace(c);var s=class extends c__namespace.ComponentResource{constructor(t,e,i){super("pkg:index:AlicloudFc3Component",t,{},i);this.name=t;this.props=e;let{enableLog:a=true,enableRam:u=true}=e,n;a&&(n=this.createLog());let r=this.createFunction(n);this.functionName=r.functionName,this.createDomain(r),u&&this.createRamUser(r),this.registerOutputs();}ak;sk;functionName;createRamUser(t){let e=new componentAlicloudRamUser.AlicloudRamUserComponent(this.name,{policy:t.functionName.apply(i=>JSON.stringify({Version:"1",Statement:[{Action:["fc:CreateService","fc:GetService"],Resource:["acs:fc:*:*:services/serverless-devs-check"],Effect:"Allow"},{Action:["fc:CreateFunction","fc:GetFunction","fc:UpdateFunction","fc:DeleteFunction"],Resource:["acs:fc:*:*:services/serverless-devs-check/functions/*"],Effect:"Allow"},{Action:["fc:CreateTrigger","fc:GetTrigger","fc:DeleteTrigger"],Resource:["acs:fc:*:*:services/serverless-devs-check/functions/*/triggers/*"],Effect:"Allow"},{Action:["fc:ListLayers"],Resource:["acs:fc:*:*:layers/*"],Effect:"Allow"},{Action:["fc:CreateLayerVersion"],Resource:["acs:fc:*:*:layers/*/versions/*"],Effect:"Allow"},{Action:["fc:GetCustomDomain","fc:CreateCustomDomain","fc:UpdateCustomDomain"],Resource:["acs:fc:*:*:custom-domains/*"],Effect:"Allow"},{Action:["fc:GetFunction","fc:UpdateFunction"],Resource:[`acs:fc:*:*:functions/${i}`],Effect:"Allow"},{Action:["fc:GetAlias","fc:CreateAlias","fc:UpdateAlias"],Resource:[`acs:fc:*:*:functions/${i}/aliases/*`],Effect:"Allow"},{Action:["fc:GetTrigger","fc:CreateTrigger","fc:UpdateTrigger","fc:DeleteTrigger"],Resource:[`acs:fc:*:*:functions/${i}/triggers/*`],Effect:"Allow"},{Action:["fc:PublishFunctionVersion"],Resource:[`acs:fc:*:*:functions/${i}/versions/*`],Effect:"Allow"}]})),enableAk:true},{parent:this});return this.ak=e.ak,this.sk=e.sk,e}createFunction(t){let e=new componentRandomSuffix.RandomSuffixComponent(this.name,{});return new o__namespace.fc.V3Function(this.name,{functionName:c__namespace.interpolate`${this.name}-${e.result}`,internetAccess:true,runtime:this.props.runtime||"custom.debian12",cpu:.05,memorySize:128,diskSize:512,code:{zipFile:"UEsDBBQACAAIAJOGJVUAAAAAAAAAAKICAAAIACAAaW5kZXguanNVVA0AB9e4FWPiuBVj17gVY3V4CwABBPUBAAAEFAAAAG2SwU7DMAyG730K35Kirr0zjQNIiHEAtMEJcchWbw1kSZekbBXau5PUKSC0Sxv7/2zHf1tdADoltZ/U0omVQrioMoUetugX4nBt6h5mYHHfSYucWXGYrEKO5dORujV29x+LSLUJwsitzgBRy/DYGutd2QhdK7SB4QEqAunaAtZGezz6HGZX8JVBjJ1RWCqz5axBpQwcjFX10AogTmqFFTsX+kQeQuibyzi3jKdiyO07tBIdpVNASoOiRpuUFJCyQ9+YmgQ6Uz5uhM6/LOakdVaRsFYStZ8/UXqMonYa7vrrLy3M0dpi8OlnW4BgIfC41Qf2IPXfC+cJoa0/heqQDB6B11DzNk1MtLN06O+GnXiQCqrJiThlZyh2E+0Pv8Zz3yIrgIm2VXItvDS6endGs1RNnpfpI8dX6c3SW6m3PCGpta75/fLxoXSDKDc9p9oCdKdUGBFZlg9Fp/AMXn0DUEsHCNdrlPNeAQAAogIAAFBLAQIUAxQACAAIAJOGJVXXa5TzXgEAAKICAAAIACAAAAAAAAAAAACkgQAAAABpbmRleC5qc1VUDQAH17gVY+K4FWPXuBVjdXgLAAEE9QEAAAQUAAAAUEsFBgAAAAABAAEAVgAAALQBAAAAAA=="},handler:"index.handler",...t?{logConfig:{logstore:t.storeName,project:t.projectName,enableInstanceMetrics:true,enableRequestMetrics:true}}:{logConfig:{}},...this.props.vpc?{vpcConfig:this.props.vpc}:{vpcConfig:{}}},{parent:this,ignoreChanges:["customRuntimeConfig"]})}createLog(){return new componentAlicloudLog.AlicloudLogComponent(this.name,{parent:this})}createDomain(t){if(this.props.domain)for(let e of this.props.domain.routes){let i=`${this.name}-${e.record}`;new o__namespace.dns.Record(i,{hostRecord:e.record,name:e.host,type:"CNAME",value:this.props.domain.cname},{parent:this}),new o__namespace.fc.V3CustomDomain(i,{customDomainName:`${e.record}.${e.host}`,routeConfig:{routes:[{path:"/*",functionName:t.functionName,qualifier:e.qualifier}]},protocol:e.cert?"HTTPS":"HTTP",...e.cert?{certConfig:{certName:e.cert.name,certificate:e.cert.pub,privateKey:e.cert.pri}}:{},wafConfig:{enableWaf:e.waf??false}},{parent:this,ignoreChanges:["certConfig","protocol"]});}}};exports.AlicloudFc3Component=s;