serverless-cloudside-plugin
serverless-cloudside-plugin copied to clipboard
!Ref AWS:AccountId returns 'RESOURCE NOT PUBLISHED'
Hi Jeremy,
Appreciate your work on this. I can see this being quite valuable but running into some roadblocks.
I'm attempting to construct an arn for an AWS::RDS::DbCluster
which is passed to the environment of a lambda function.
Originally I was using serverless-pseudo-parameters to return a string like so :
environment:
DbClusterArn: "arn:aws:rds:${self:provider.region}:#{AWS::AccountId}:cluster:#{AuroraCluster}"
However it appears that serverless-pseudo-parameters + serverless-cloudside-plugin don't play well together.
So I broke out each parameter into a separate env var and constructed the arn in the lambda function:
environment:
DbClusterId: !Ref AuroraCluster
AccountId: !Ref "AWS::AccountId"
Region: ${self:provider.region}
However the AccountId
returns <Resource Not Published>
.
My questions are:
- Should this work nicely with serverless-pseudo-parameters?
- Should refs to pseudo parameters work?
Hi Matt,
I don't believe that !Ref "AWS::AccountId"
is actually valid CloudFormation syntax. I could totally be wrong, but I think using pseudo parameters would be better in that case. What were the conflicts with the serverless-pseudo-parameters
plugin? I will have to run some tests to figure out what the issue is.
Thanks, Jeremy
I don't believe that !Ref "AWS::AccountId" is actually valid CloudFormation syntax
I see, I was going off of the pseudo parameters docs but wasn't sure how it was supposed to be represented in the serverless.yml file.
What were the conflicts with the serverless-pseudo-parameters plugin?
If I were to use serverless-pseudo-parameters
, like so:
environment:
AccountId: "#{AWS::AccountId}"
Then the variable resolves to the literal string "#{AWS::AccountId}"
in my function.
Hey Jeremy, thanks for making this.
I ran into the same problem as Matt. I ended up using the Serverless Framework Pro deployment profile feature to inject the account ID as a parameter like: ${param: ACCOUNT_ID}
I assigned that to an environment variable and constructed the RDS cluster ARN inside the function code like this:
arn:aws:rds:${REGION}:${ACCOUNT_ID}:cluster:${CLUSTER_ID}
Now I can run sls offline cloudside
and use RDS Aurora Serverless in local dev.
I tried outputting the aurora cluster ARN in the resources section using Fn:Join
to construct but that didn't seem to work. From what I understand the cloudside plugin is looking for Ref
and GetAtt
so thinking the Fn:Join
wasn't getting pulled in.
@MattNguyen did you resolve your issue. i'm getting TypeError: bucketName.charAt is not a function when using "#{AWS::StackName}-my-bucket"