fog/fog-aws

ECS IAM role not working

FedorMutovin-flatstack opened this issue · 1 comments

I'm trying to run the ecs task with this config:

config.fog_provider = 'fog/aws'
config.fog_credentials = {
        provider: 'AWS',
        use_iam_profile: true,
        region: ENV["AWS_REGION"]
      }
config.fog_attributes = { 'x-amz-server-side-encryption' => 'AES256' }
config.fog_directory = ENV["BUCKET"]

and keep getting this error

[fog][WARNING] Unable to fetch credentials: Invalid argument - connect(2) for 169.254.169.254:80 (Errno::EINVAL)
/home/user/app/vendor/bundle/ruby/2.7.0/gems/fog-core-2.2.3/lib/fog/core/service.rb:244:in `validate_options': Missing required arguments: aws_access_key_id, aws_secret_access_key (ArgumentError)

but I see that I can get credentials by curl 169.254.170.2$AWS_CONTAINER_CREDENTIALS_RELATIVE_URI and I'm not clear on what connect(2) argument might mean in this case.

I'm not sure off hand. Looking at what you have here it looks like fog is trying to connect to 169.254.169.254:80 vs curl which appears to be using 169.254.170.2. The different in the 4th group and the explicit port could both be sources of the differences. I don't have any direct experience with using ECS this way though, so it's all a bit speculative from my perspective. Could those issues be part of the problem, or maybe it's something else altogether?