Cannot Set AWS_ENDPOINT_URL_S3 Without DNS Mapping
For the use case where the localstack instance is on a remote server, the environment variables AWS_ENDPOINT_URL and AWS_ENDPOINT_URL_S3 must be set. It should be noted that this requirement appears to have been added when LOCALSTACK_HOSTNAME was deprecated. The problem with setting the AWS_ENDPOINT_URL_S3 variable is the additional requirement that the "server" be in the format of s3.servername.domain which will never resolve correctly without a DNS mapping.
aws-cdk-local version: 3.0.1
Error messages when trying to bootstrap the localstack environment (S3 upload errors):
XXXXXXStack: fail: getaddrinfo ENOTFOUND cdk-hnb659fds-assets-000000000000-us-east-1.s3.servername.domain
Hi, thanks for posting this issue. You are right this is a problem that we have seen before. We are working on a solution.
Context: the problem is:
- the CDK performs an S3 PutObject to upload the CFn template
- this request (by default) is sent to
<bucket>.s3.<$AWS_ENDPOINT_URL>/<key>so requires subdomains - if configuring "path style" addressing, it is still sent to
s3.<$AWS_ENDPOINT_URL>/<bucket>/<key>which requires subdomains - we default to setting
AWS_ENDPOINT_URL_S3to enforce the subdomain is added, otherwise the request is directed to CloudFormation which cannot parse the template as an API request - when using
localhost.localstack.cloudwe allow subdomains, so this all works out of the box
This behaviour is hard-coded in the CDK, and since version 2.177 we cannot monkeypatch the package to support our own use cases, which is what we used to do.
One idea I've had is to start a proxy server which rewrites S3 requests to a format that LocalStack always supports (docs here), or to add another method of detecting this request, via a custom header or something. Unfortunately this is WIP, but I'll keep this issue updated.
Hi, thanks @simonrw. We have the same issue. Do you possibly have any updates or an ETA?
"aws-cdk": "^2.193.0",
"aws-cdk-local": "^3.0.1",
Update
My problem got solved by using the static IP of the localstack service as described here.
- the CDK performs an S3 PutObject to upload the CFn template
- this request (by default) is sent to
.s3.<$AWS_ENDPOINT_URL>/ so requires subdomains - if configuring "path style" addressing, it is still sent to s3.<$AWS_ENDPOINT_URL>/
/ which requires subdomains
@simonrw Is there an issue on https://github.com/aws/aws-cdk about this? It seems this issue can't be fixed in aws-cdk-local until aws-cdk respects s3ForcePathStyle?