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

!Ref AWS:AccountId returns 'RESOURCE NOT PUBLISHED' #4

Open
MattNguyen opened this issue Jun 3, 2019 · 4 comments
Open

!Ref AWS:AccountId returns 'RESOURCE NOT PUBLISHED' #4

MattNguyen opened this issue Jun 3, 2019 · 4 comments

Comments

@MattNguyen
Copy link

MattNguyen commented Jun 3, 2019

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:

  1. Should this work nicely with serverless-pseudo-parameters?
  2. Should refs to pseudo parameters work?
@jeremydaly
Copy link
Owner

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

@MattNguyen
Copy link
Author

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.

@davegariepy
Copy link

davegariepy commented May 21, 2020

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.

@matjamesymj
Copy link

@MattNguyen did you resolve your issue. i'm getting TypeError: bucketName.charAt is not a function when using "#{AWS::StackName}-my-bucket"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants