train icon indicating copy to clipboard operation
train copied to clipboard

Consistent handling for connectivity issues

Open chris-rock opened this issue 5 years ago • 1 comments

Description

Most train backends for cloud (e.g. aws and azure) are not handling authentication issues properly. Users will see a stacktrace of errors if something is going wrong. We intentionally created different error classes in Train to handle this properly. Instead each resource needs to handle connectivity errors at this point. See https://github.com/inspec/inspec/blob/7deed13425c299ded99ff6e4095b1e0db969a826/lib/resources/aws/aws_iam_root_user.rb#L20-L25

Strangely inspec detect returns fine.

inspec detect -t aws://

== Platform Details

Name:      aws
Families:  cloud, api
Release:   aws-sdk-v2.11.35

But when I run a profile, things are handled in inspec resources only.

$ inspec exec https://github.com/chris-rock/aws-baseline -t aws://us-east1
transformed to https://github.com/chris-rock/aws-baseline/archive/master.tar.gz. Consider using the git fetcher
[2018-10-11T16:10:07+02:00] ERROR: It appears that you have not set your AWS credentials.  You may set them using environment variables, or using the 'aws://region/aws_credentials_profile' target.  See https://www.inspec.io/docs/reference/platforms for details.
[2018-10-11T16:10:07+02:00] ERROR: It appears that you have not set your AWS credentials.  You may set them using environment variables, or using the 'aws://region/aws_credentials_profile' target.  See https://www.inspec.io/docs/reference/platforms for details.
unable to sign request without credentials set

This issue is related to https://github.com/inspec/inspec/issues/2881 and https://github.com/inspec/inspec/issues/2976

Train and Platform Version

1.5.1

Replication Case

See above

Possible Solutions

This behaviour should be consistent with ssh, docker and winrm. Train connections could easily raise issues:

       # check account to verify authentication
        begin
          @uuid = droplet_client.account.info.uuid
        rescue DropletKit::Error
          raise Train::TransportError, msg
        end

chris-rock avatar Oct 11 '18 14:10 chris-rock

refs #352

clintoncwolfe avatar Oct 25 '18 18:10 clintoncwolfe