Why AWS Service Connect does not work in my tasks?

I’m new guy in AWS Amazone ecosystem. I want to deploy 2 services. First one is Spring-Boot application and second one will contain Mongodb. Spring microservice contains Mongock, which is up when application is started and it performs migrations to database. I want to do a simple deploy, using ECS. What I did first:

  • created fargate cluster in order to create and start services in ecs there.
  • built mongo image, pushed to ECR repo, built Task definition, depoyed Service with minimum 1 task. Ok, database was setup.
  • then I copied mongo task public ip, set it as host to spring application properties, built spring image, pushed to ECR, started Service and task.

On this moment all worked fine – mongock connected to mongo service and applied migrations. As we know every task has dynamic ip, and I dont plan to have running tasks non-stop. After googling I found solution – Service Connect and decided to give DNS-names, in order task agent could find where to push requests.
For mongodb service I pushed next config using aws cli:

{
  "enabled": true,
  "namespace": "test",
  "services": [
    {
      "portName": "27017mongo",
      "discoveryName": "user-mongo",
      "clientAliases": [
        {
          "port": 27017
        }
      ]
    }
  ]
}

After that I checked service-described:

serviceConnectConfiguration": {
                    "enabled": true,
                    "namespace": "arn:aws:servicediscovery:eu-north-1:891377330754:namespace/ns-p76w3mzvv5py466a",
                    "services": [
                        {
                            "portName": "27017mongo",
                            "discoveryName": "user-mongo",
                            "clientAliases": [
                                {
                                    "port": 27017,
                                    "dnsName": "user-mongo.test"
                                }
                            ]
                        }
                    ]
                },
                "serviceConnectResources": [
                    {
                        "discoveryName": "user-mongo",
                        "discoveryArn": "arn:aws:servicediscovery:eu-north-1:891377330754:service/srv-rqiink64a7izgkdy"
                    }
                ]
            },

From what I see, DNS name was registered normally. In service appeared new task container ecs-service-connect in pair with user-mongo container.

I went next. Set hostname to spring props:

  data:
    mongodb:
      uri: mongodb://user-mongo.test:27017/iAutoService02

      auto-index-creation: true
      database: iAutoService02
      port: 27017
      host: user-mongo.test

After that I deployed service and uploaded connect config:

{
  "enabled": true,
  "namespace": "test",
  "services": [
    {
      "portName": "8083user",
      "discoveryName": "user-service",
      "clientAliases": [
        {
          "port": 8083
        }
      ]
    }
  ]
}

So both services are in ‘test’ cluster namespace. Spring service was updated, ecs-service-connect appeared too. And I considered things done, but suddenly Spring task fell down. I checked the logs:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'getBuilder' defined in io.mongock.runner.springboot.config.MongockContext: Unsatisfied dependency expressed through method 'getBuilder' parameter 0: Error creating bean with name 'connectionDriver' defined in class path resource [io/mongock/driver/mongodb/springdata/v4/config/SpringDataMongoV4Context.class]: Failed to instantiate [io.mongock.driver.api.driver.ConnectionDriver]: Factory method 'connectionDriver' threw exception with message: Timed out after 30000 ms while waiting to connect. Client view of cluster state is {type=UNKNOWN, servers=[{address=user-mongo.test:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketException: user-mongo.test}, caused by {java.net.UnknownHostException: user-mongo.test}}]

From what I see – Service cannot connect to database, because can not resolve

user-mongo.test

host. Unfortunately, I didnt find any solution. What I’m doing wrong? how to make my aws task to see each other?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật