StackStorm-Exchange / stackstorm-aws

st2 content pack containing Amazon Web Services integrations.
https://exchange.stackstorm.org/
Apache License 2.0
15 stars 26 forks source link

aws.s3_{down,up}load_file not working #72

Closed jjacque closed 6 years ago

jjacque commented 6 years ago

Hi, i've an issue with those 2 functions , it seems the way boto3.client is called is an issue:

st2 run aws.s3_download_file filename="/tmp/toto12345" bucket="test-bucket" key="st2-test-1"
.
id: 5bd8376c2239205175d29e9d
status: failed
parameters:
  bucket: test-bucket
  filename: /tmp/toto12345
  key: st2-test-1
result:
  exit_code: 1
  result: None
  stderr: "st2.actions.python.ActionManager: DEBUG    Calling method "boto3.s3.transfer.S3Transfer.download_file" with kwargs: {u'headers': None, u'bucket': u'test-bucket', u'key': u'st2-test-1', u'filename': u'/tmp/toto12345'}
Traceback (most recent call last):
  File "/opt/stackstorm/runners/python_runner/python_runner/python_action_wrapper.py", line 320, in <module>
    obj.run()
  File "/opt/stackstorm/runners/python_runner/python_runner/python_action_wrapper.py", line 179, in run
    output = action.run(**self._parameters)
  File "/opt/stackstorm/packs/aws/actions/run.py", line 35, in run
    return self.do_method(module_path, cls, aws_action, **kwargs)
  File "/opt/stackstorm/packs/aws/actions/lib/action.py", line 162, in do_method
    obj = self.get_boto3_session(cls)
  File "/opt/stackstorm/packs/aws/actions/lib/action.py", line 92, in get_boto3_session
    return boto3.client(resource, region_name=region, **self.credentials)
  File "/opt/stackstorm/virtualenvs/aws/lib/python2.7/site-packages/boto3/__init__.py", line 79, in client
    return _get_default_session().client(*args, **kwargs)
  File "/opt/stackstorm/virtualenvs/aws/lib/python2.7/site-packages/boto3/session.py", line 250, in client
    aws_session_token=aws_session_token, config=config)
  File "/opt/stackstorm/virtualenvs/aws/lib/python2.7/site-packages/botocore/session.py", line 889, in create_client
    client_config=config, api_version=api_version)
  File "/opt/stackstorm/virtualenvs/aws/lib/python2.7/site-packages/botocore/client.py", line 69, in create_client
    service_model = self._load_service_model(service_name, api_version)
  File "/opt/stackstorm/virtualenvs/aws/lib/python2.7/site-packages/botocore/client.py", line 104, in _load_service_model
    api_version=api_version)
  File "/opt/stackstorm/virtualenvs/aws/lib/python2.7/site-packages/botocore/loaders.py", line 132, in _wrapper
    data = func(self, *args, **kwargs)
  File "/opt/stackstorm/virtualenvs/aws/lib/python2.7/site-packages/botocore/loaders.py", line 378, in load_service_model
    known_service_names=', '.join(sorted(known_services)))
botocore.exceptions.UnknownServiceError: Unknown service: 'S3Transfer'. Valid service names are: acm, acm-pca, alexaforbusiness, apigateway, application-autoscaling, appstream, appsync, athena, autoscaling, autoscaling-plans, batch, budgets, ce, cloud9, clouddirectory, cloudformation, cloudfront, cloudhsm, cloudhsmv2, cloudsearch, cloudsearchdomain, cloudtrail, cloudwatch, codebuild, codecommit, codedeploy, codepipeline, codestar, cognito-identity, cognito-idp, cognito-sync, comprehend, config, connect, cur, datapipeline, dax, devicefarm, directconnect, discovery, dlm, dms, ds, dynamodb, dynamodbstreams, ec2, ecr, ecs, efs, eks, elasticache, elasticbeanstalk, elastictranscoder, elb, elbv2, emr, es, events, firehose, fms, gamelift, glacier, glue, greengrass, guardduty, health, iam, importexport, inspector, iot, iot-data, iot-jobs-data, iot1click-devices, iot1click-projects, iotanalytics, kinesis, kinesis-video-archived-media, kinesis-video-media, kinesisanalytics, kinesisvideo, kms, lambda, lex-models, lex-runtime, lightsail, logs, machinelearning, macie, marketplace-entitlement, marketplacecommerceanalytics, mediaconvert, medialive, mediapackage, mediastore, mediastore-data, mediatailor, meteringmarketplace, mgh, mobile, mq, mturk, neptune, opsworks, opsworkscm, organizations, pi, pinpoint, polly, pricing, rds, redshift, rekognition, resource-groups, resourcegroupstaggingapi, route53, route53domains, s3, sagemaker, sagemaker-runtime, sdb, secretsmanager, serverlessrepo, servicecatalog, servicediscovery, ses, shield, signer, sms, snowball, sns, sqs, ssm, stepfunctions, storagegateway, sts, support, swf, transcribe, translate, waf, waf-regional, workdocs, workmail, workspaces, xray
"

I managed to get it work with the following changes #71 Not sure that's the best way but it fixes the issue leaving parameters unchanged.

st2 --version
st2 2.9.1, on Python 2.7.12
LindsayHill commented 6 years ago

Resolved with #71