<p>Did you try the variable <code>ServerlessRestApi</code>? It works for us like this:</p>

<pre><code>Outputs:    
    EncryptURL:
      Description: "Encrypt endpoint URL for Stage environment"
      Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Stage/encrypt"
</code></pre>

CC BY-SA 4.0
2018-10-13T14:43:48.507Z
Hey thanks. Yep! That was it! I had to reference the actual RestApi resource. I was referencing the method resource.
Dr. Chocolate
CC BY-SA 4.0
2018-10-13T16:58:56.123Z
@mutant_city Cool!
Niklas Rosencrantz
CC BY-SA 4.0
2018-10-12T06:02:12.943Z
2018-10-12T06:02:12.943Z
Niklas Rosencrantz
<p><a href="https://u1i7vf9mnl.execute-api.us-west-1.amazonaws.com/v1" rel="nofollow noreferrer">https://u1i7vf9mnl.execute-api.us-west-1.amazonaws.com/v1</a></p>

<p>How can I get the u1i7vf9mnl portion of the URL from inside of the cloudformation template as a Ref or Fn::GetAtt or some other way?</p>

<api><aws-cloudformation>
How can I get the first part of the API Deployment URL from inside cloud formation template?
Dr. Chocolate
# How can I get the first part of the API Deployment URL from inside cloud formation template?

(Asked by: username_0 on 2018-10-03)

<https://u1i7vf9mnl.execute-api.us-west-1.amazonaws.com/v1>

How can I get the u1i7vf9mnl portion of the URL from inside of the cloudformation template as a Ref or Fn::GetAtt or some other way?

**Tags:** api, aws-cloudformation


---

## 1 answers

### Answer by username_1 on 2018-10-12. Score: 2 | Accepted answer

Did you try the variable ServerlessRestApi? It works for us like this:
Outputs:    
    EncryptURL:
      Description: "Encrypt endpoint URL for Stage environment"
      Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Stage/encrypt"

> **Comments:**
> **username_0**: Hey thanks. Yep! That was it! I had to reference the actual RestApi resource. I was referencing the method resource.  
> **username_1**: @mutant_city Cool!  

---

