# Is It Possible to Reference CFN Outputs in iamRoleStatements?

**URL:** <https://forum.serverless.com/t/is-it-possible-to-reference-cfn-outputs-in-iamrolestatements/8570>\
**Category:** Serverless Framework\
**Tags:** aws, lambda, cloudformation, variables, iam\
**Created:** [June 17, 2019, 9:42pm UTC](https://forum.serverless.com/t/is-it-possible-to-reference-cfn-outputs-in-iamrolestatements/8570 "2019-06-17T21:42:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![wenindoubt](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/wenindoubt/32/3410_2.png) [@wenindoubt](https://forum.serverless.com/u/wenindoubt)\
**Post date:** [June 17, 2019, 9:42pm UTC](https://forum.serverless.com/t/is-it-possible-to-reference-cfn-outputs-in-iamrolestatements/8570/1 "2019-06-17T21:42:59Z")

</div>

I would like to reference a resource’s ARN in my **iamRoleStatements**. Currently, this is only possible if the CognitoUserPool resource is deployed **first**.

```
provider:
  name: aws
  runtime: nodejs8.10
  iamRoleStatements:
    - Effect: Allow
      Action:
        - cognito-idp:AdminGetUser
      Resource:
        - Fn::GetAtt: ["CognitoUserPoolMyUserPool", "Arn"]

resources:
  Resources:
    CognitoUserPoolMyUserPool:
      Type: AWS::Cognito::UserPool
      Properties:
        AutoVerifiedAttributes:
          - email

```

I have seen solutions where the CognitoUserPool resource would be defined elsewhere (another CFN stack, etc). Then, I can reference the \<stack\_name.output\> in my **iamRoleStatements**.

Unfortunately, the above will not work for me because I am **also** trying to override an existing Cognito User Pool ([https://serverless.com/framework/docs/providers/aws/events/cognito-user-pool#overriding-a-generated-user-pool](https://serverless.com/framework/docs/providers/aws/events/cognito-user-pool#overriding-a-generated-user-pool))

Therefore, I **need** the CognitoUserPool resource to be in the same `serverless.yml` as my iamRoleStatements.

---

<div class="post-metadata">

**Author:** ![buggy](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/buggy/32/177_2.png) [@buggy](https://forum.serverless.com/u/buggy)\
**Post date:** [June 21, 2019, 10:30am UTC](https://forum.serverless.com/t/is-it-possible-to-reference-cfn-outputs-in-iamrolestatements/8570/2 "2019-06-21T10:30:29Z")

</div>

It depends why it’s not working. Is this creating a circular dependency? If it is then using [https://github.com/functionalone/serverless-iam-roles-per-function](https://github.com/functionalone/serverless-iam-roles-per-function) to implement per function IAM roles might solve the problem.

---

<div class="post-metadata">

**Author:** ![wenindoubt](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/wenindoubt/32/3410_2.png) [@wenindoubt](https://forum.serverless.com/u/wenindoubt)\
**Post date:** [June 21, 2019, 2:14pm UTC](https://forum.serverless.com/t/is-it-possible-to-reference-cfn-outputs-in-iamrolestatements/8570/3 "2019-06-21T14:14:53Z")

</div>

Yeah! I’m running into circular dependency issues. Can you explain why this might solve the problem?

---

<div class="post-metadata">

**Author:** ![buggy](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/buggy/32/177_2.png) [@buggy](https://forum.serverless.com/u/buggy)\
**Post date:** [June 22, 2019, 5:32am UTC](https://forum.serverless.com/t/is-it-possible-to-reference-cfn-outputs-in-iamrolestatements/8570/4 "2019-06-22T05:32:20Z")

</div>

Serverless creates one role that is shared by all Lambda so if one has a dependency on Cognito User Pools they all do. When this has happend to me in the past it’s because one of those Lambda was actually a Lambda trigger on the User Pool and shouldn’t have a dependency on it. Without seeing the full serverless.yml it’s impossible to understand if setting up per Lambda IAM roles will help.
