Skip to content

Conversation

joe4dev
Copy link

@joe4dev joe4dev commented Sep 9, 2025

Hardcoded endpoints such as amazonaws.com are incompatible with custom endpoint URLs (e.g., AWS_ENDPOINT_URL): https://docs.aws.amazon.com/sdkref/latest/guide/feature-ss-endpoints.html

Using the CloudFormation pseudo parameter ${AWS::URLSuffix} (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/pseudo-parameter-reference.html#cfn-pseudo-param-urlsuffix) fixes this issue as demonstrated for the AWS SAM templates aws/aws-sam-cli-app-templates#525

Issue #, if available: N/A

Description of changes: Replace hardcoded amazonaws.com domain in template.yaml output value with ${AWS::URLSuffix}. The parameter ${AWS::URLSuffix} evaluates to amazonaws.com in most cases, but respects custom endpoint URLs used, for example, in emulators such as LocalStack.

Disclaimer: I work for LocalStack

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@@ -1,32 +1,32 @@
---
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: This file used ^M newlines, which I converted using dos2unix apigw-http-api-lambda-dotnet-sam/template.yaml

ApiURL:
Description: API endpoint URL for Prod environment
Value:
Fn::Sub: https://${ServerlessRestApi}.execute-api.${AWS::Region}.${AWS::URLSuffix}/Prod/
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line contains the only change, replacing amazonaws.com with ${AWS::URLSuffix}

@@ -270,7 +270,7 @@ Resources:
- - service
- !Ref ECSCluster
- !GetAtt ECSService.Name
RoleARN: !Sub arn:aws:iam::${AWS::AccountId}:role/aws-service-role/ecs.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_ECSService
RoleARN: !Sub arn:aws:iam::${AWS::AccountId}:role/aws-service-role/ecs.application-autoscaling.${AWS::URLSuffix}/AWSServiceRoleForApplicationAutoScaling_ECSService
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not an output URL (as most other changes), but likely still relevant

@@ -145,7 +145,7 @@ Resources:
from aws_synthetics.common import synthetics_logger as logger

def main():
url = "https://${RestApi}.execute-api.${AWS::Region}.amazonaws.com/${RestApi.Stage}"
url = "https://${RestApi}.execute-api.${AWS::Region}.${AWS::URLSuffix}/${RestApi.Stage}"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Special case: Not a direct output URL (as most other changes), but composed dynamically in a Selenium context.

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

Successfully merging this pull request may close these issues.

3 participants