Description
This is in reference to https://github.com/localstack/docs/edit/main/content/en/user-guide/ci/gitlab-ci/index.md
I think the root of this problem is that the documentation conflates two different ways of running LocalStack in GitLab -- one is directly a "service" and one manually via Docker-in-Docker. I think these should be separated, as only one of the services needs to be used.
I tried using only the service definition in the documentation, as this typically works with other services (like databases).
services:
- name: localstack/localstack:latest
alias: localstack
However, my tests were unable to connect to the service with the same configuration when I run LocalStack locally using the same compose file documented here, at http://localhost.localstack.cloud:4566
.
The underlying problem is that the specification of alias localstack
sets up a DNS entry to use that as the hostname, rather than localhost.localstack.cloud, which I didn't know enough about GitLab CI service definitions to understand. Changing this to:
services:
- name: localstack/localstack:4
alias: localhost.localstack.cloud
works, with none of the other variables and script commands in that documentation page.
However, I later discovered that the public DNS entry localhost.localstack.cloud -> 127.0.0.1 doesn't work with routers that have DNS rebind protection turned on, so we decided to not use that at all.
Instead, I used this as my CI definition:
services:
- name: localstack/localstack:4
alias: localstack
variables:
- AWS_ENDPOINT_URL: http://localstack:4566
and then in my Python pytest tests, configured the variable with the D
"don't override" prefix so the GitLab CI configuration will be used instead:
[tool.pytest.ini_options]
env = [
"D:AWS_ENDPOINT_URL=http://localhost:4566"
]