# Referencing resource ARNs in environment variables

**URL:** <https://forum.serverless.com/t/referencing-resource-arns-in-environment-variables/16612>\
**Category:** Serverless Framework\
**Tags:** aws\
**Created:** [January 26, 2022, 10:28am UTC](https://forum.serverless.com/t/referencing-resource-arns-in-environment-variables/16612 "2022-01-26T10:28:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mschae](https://avatars.discourse-cdn.com/v4/letter/m/b38774/32.png) [@mschae](https://forum.serverless.com/u/mschae)\
**Post date:** [January 26, 2022, 10:28am UTC](https://forum.serverless.com/t/referencing-resource-arns-in-environment-variables/16612/1 "2022-01-26T10:28:30Z")

</div>

Hey all,

I searched all over but couldn’t find the answer to the following problem: I am creating a role in `resources` whose ARN I need to address in a function.  
Using `!Ref roleForSomething` doesn’t work, as it references the name, not the ARN, which AWS doesn’t like. I have a solution that’s working for AWS but unfortunately Serverless can’t make sense of it (business case is using async Textract when a file is uploaded in S3 and then doing something when Textract is finished, which we know by subscribing to a SNS topic that Textract has to publish to:

```auto
functions:
  ocr:
    handler: handler.ocr
    events:
      - s3:
          bucket: ${self:custom.bucket}
          event: s3:ObjectCreated:*
          existing: true
    environment:
      SNS_TOPIC: !Ref textractTopic
      SNS_ROLE:
        'Fn::GetAtt': ['iamRole', 'Arn']

  handler.doSomething:
    handler: handler.doSomething
    events:
      - sns:
          arn: !Ref textractTopic
          topicName: ${self:custom.sns-topic}

resources:
  Resources:
    textractTopic:
      Type: AWS::SNS::Topic
      Properties:
        TopicName: ${self:custom.sns-topic}
    iamRole:
      Type: AWS::IAM::Role
      Properties:
        RoleName: ${self:custom.role-name}
        AssumeRolePolicyDocument:
          Version: '2012-10-17'
          Statement:
            - Effect: Allow
              Principal:
                Service:
                  - textract.amazonaws.com
              Action: sts:AssumeRole
        Policies:
          - PolicyName: textratct-sns-publishing
            PolicyDocument:
              Version: '2012-10-17'
              Statement:
                - Effect: Allow
                  Action:
                    - sns:*
                  Resource:
                    - !Ref textractTopic

```

How du I replace this:

```auto
    environment:
      SNS_ROLE:
        'Fn::GetAtt': ['iamRole', 'Arn']

```

with something that works for Serverless?

Thank you!  
Michael

---

<div class="post-metadata">

**Author:** ![rolo-er](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/rolo-er/32/6933_2.png) [@rolo-er](https://forum.serverless.com/u/rolo-er)\
**Post date:** [June 25, 2022, 11:41pm UTC](https://forum.serverless.com/t/referencing-resource-arns-in-environment-variables/16612/2 "2022-06-25T23:41:12Z")

</div>

Did you find a solution for this? I am in the same situation
