-
Notifications
You must be signed in to change notification settings - Fork 998
Fix hardcoded AWS endpoint using CloudFormation pseudo parameter #2833
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
base: main
Are you sure you want to change the base?
Conversation
@@ -1,32 +1,32 @@ | |||
--- |
There was a problem hiding this comment.
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/ |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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}" |
There was a problem hiding this comment.
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.
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.htmlaws-us-gov
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#525Issue #, if available: N/A
Description of changes: Replace hardcoded
amazonaws.com
domain intemplate.yaml
output value with${AWS::URLSuffix}
. The parameter${AWS::URLSuffix}
evaluates toamazonaws.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.