How to use role_arn method in localstack

Best Python code snippet using localstack_python

s3.py

Source:s3.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2"""3Connection module for Amazon S34.. highlight:: yaml5:configuration: This module accepts explicit s3 credentials but can also utilize6 IAM roles assigned to the instance through Instance Profiles. Dynamic7 credentials are then automatically obtained from AWS API and no further8 configuration is necessary. More Information available at:9 http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html10 If IAM roles are not used you need to specify them either in a pillar or11 in the minion's config file::12 s3.keyid: GKTADJGHEIQSXMKKRBJ08H13 s3.key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs14 .. warning:: This is literally the pillar key ``s3.keyid`` or the config option ``s3.keyid``,15 not::16 s3:17 keyid: blah18 A ``service_url`` may also be specified in the configuration::19 s3.service_url: s3.amazonaws.com20 A ``role_arn`` may also be specified in the configuration::21 s3.role_arn: arn:aws:iam::111111111111:role/my-role-to-assume22 If a ``service_url`` is not specified, the default is ``s3.amazonaws.com``. This23 may appear in various documentation as an "endpoint". A comprehensive list24 for Amazon S3 may be found at:25 http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region26 The ``service_url`` will form the basis for the final endpoint that is used to27 query the service.28 Path style can be enabled::29 s3.path_style: True30 This can be useful if you need to use Salt with a proxy for a S3 compatible storage.31 You can use either HTTPS protocol or HTTP protocol::32 s3.https_enable: True33 SSL verification may also be turned off in the configuration::34 s3.verify_ssl: False35 This is required if using S3 bucket names that contain a period, as36 these will not match Amazon's S3 wildcard certificates. Certificate37 verification is enabled by default.38 AWS region may be specified in the configuration::39 s3.location: eu-central-140 Default is ``us-east-1``.41 This module should be usable to query other S3-like services, such as42 Eucalyptus.43.. highlight:: bash44:depends: requests45"""46from __future__ import absolute_import, print_function, unicode_literals47# Import Python libs48import logging49log = logging.getLogger(__name__)50def __virtual__():51 """52 Should work on any modern Python installation53 """54 return True55def delete(56 bucket,57 path=None,58 action=None,59 key=None,60 keyid=None,61 service_url=None,62 verify_ssl=None,63 kms_keyid=None,64 location=None,65 role_arn=None,66 path_style=None,67 https_enable=None,68):69 """70 Delete a bucket, or delete an object from a bucket.71 CLI Example to delete a bucket::72 salt myminion s3.delete mybucket73 CLI Example to delete an object from a bucket::74 salt myminion s3.delete mybucket remoteobject75 """76 (77 key,78 keyid,79 service_url,80 verify_ssl,81 kms_keyid,82 location,83 role_arn,84 path_style,85 https_enable,86 ) = _get_key(87 key,88 keyid,89 service_url,90 verify_ssl,91 kms_keyid,92 location,93 role_arn,94 path_style,95 https_enable,96 )97 return __utils__["s3.query"](98 method="DELETE",99 bucket=bucket,100 path=path,101 action=action,102 key=key,103 keyid=keyid,104 kms_keyid=kms_keyid,105 service_url=service_url,106 verify_ssl=verify_ssl,107 location=location,108 role_arn=role_arn,109 path_style=path_style,110 https_enable=https_enable,111 )112def get(113 bucket="",114 path="",115 return_bin=False,116 action=None,117 local_file=None,118 key=None,119 keyid=None,120 service_url=None,121 verify_ssl=None,122 kms_keyid=None,123 location=None,124 role_arn=None,125 path_style=None,126 https_enable=None,127):128 """129 List the contents of a bucket, or return an object from a bucket. Set130 return_bin to True in order to retrieve an object wholesale. Otherwise,131 Salt will attempt to parse an XML response.132 CLI Example to list buckets:133 salt myminion s3.get134 CLI Example to list the contents of a bucket:135 salt myminion s3.get mybucket136 CLI Example to return the binary contents of an object:137 salt myminion s3.get mybucket myfile.png return_bin=True138 CLI Example to save the binary contents of an object to a local file:139 salt myminion s3.get mybucket myfile.png local_file=/tmp/myfile.png140 It is also possible to perform an action on a bucket. Currently, S3141 supports the following actions::142 acl143 cors144 lifecycle145 policy146 location147 logging148 notification149 tagging150 versions151 requestPayment152 versioning153 website154 To perform an action on a bucket:155 salt myminion s3.get mybucket myfile.png action=acl156 """157 (158 key,159 keyid,160 service_url,161 verify_ssl,162 kms_keyid,163 location,164 role_arn,165 path_style,166 https_enable,167 ) = _get_key(168 key,169 keyid,170 service_url,171 verify_ssl,172 kms_keyid,173 location,174 role_arn,175 path_style,176 https_enable,177 )178 return __utils__["s3.query"](179 method="GET",180 bucket=bucket,181 path=path,182 return_bin=return_bin,183 local_file=local_file,184 action=action,185 key=key,186 keyid=keyid,187 kms_keyid=kms_keyid,188 service_url=service_url,189 verify_ssl=verify_ssl,190 location=location,191 role_arn=role_arn,192 path_style=path_style,193 https_enable=https_enable,194 )195def head(196 bucket,197 path="",198 key=None,199 keyid=None,200 service_url=None,201 verify_ssl=None,202 kms_keyid=None,203 location=None,204 role_arn=None,205 path_style=None,206 https_enable=None,207):208 """209 Return the metadata for a bucket, or an object in a bucket.210 CLI Examples:211 salt myminion s3.head mybucket212 salt myminion s3.head mybucket myfile.png213 """214 (215 key,216 keyid,217 service_url,218 verify_ssl,219 kms_keyid,220 location,221 role_arn,222 path_style,223 https_enable,224 ) = _get_key(225 key,226 keyid,227 service_url,228 verify_ssl,229 kms_keyid,230 location,231 role_arn,232 path_style,233 https_enable,234 )235 return __utils__["s3.query"](236 method="HEAD",237 bucket=bucket,238 path=path,239 key=key,240 keyid=keyid,241 kms_keyid=kms_keyid,242 service_url=service_url,243 verify_ssl=verify_ssl,244 location=location,245 full_headers=True,246 role_arn=role_arn,247 path_style=path_style,248 https_enable=https_enable,249 )250def put(251 bucket,252 path=None,253 return_bin=False,254 action=None,255 local_file=None,256 key=None,257 keyid=None,258 service_url=None,259 verify_ssl=None,260 kms_keyid=None,261 location=None,262 role_arn=None,263 path_style=None,264 https_enable=None,265):266 """267 Create a new bucket, or upload an object to a bucket.268 CLI Example to create a bucket:269 salt myminion s3.put mybucket270 CLI Example to upload an object to a bucket:271 salt myminion s3.put mybucket remotepath local_file=/path/to/file272 """273 (274 key,275 keyid,276 service_url,277 verify_ssl,278 kms_keyid,279 location,280 role_arn,281 path_style,282 https_enable,283 ) = _get_key(284 key,285 keyid,286 service_url,287 verify_ssl,288 kms_keyid,289 location,290 role_arn,291 path_style,292 https_enable,293 )294 return __utils__["s3.query"](295 method="PUT",296 bucket=bucket,297 path=path,298 return_bin=return_bin,299 local_file=local_file,300 action=action,301 key=key,302 keyid=keyid,303 kms_keyid=kms_keyid,304 service_url=service_url,305 verify_ssl=verify_ssl,306 location=location,307 role_arn=role_arn,308 path_style=path_style,309 https_enable=https_enable,310 )311def _get_key(312 key,313 keyid,314 service_url,315 verify_ssl,316 kms_keyid,317 location,318 role_arn,319 path_style,320 https_enable,321):322 """323 Examine the keys, and populate as necessary324 """325 if not key and __salt__["config.option"]("s3.key"):326 key = __salt__["config.option"]("s3.key")327 if not keyid and __salt__["config.option"]("s3.keyid"):328 keyid = __salt__["config.option"]("s3.keyid")329 if not kms_keyid and __salt__["config.option"]("aws.kms.keyid"):330 kms_keyid = __salt__["config.option"]("aws.kms.keyid")331 if not service_url and __salt__["config.option"]("s3.service_url"):332 service_url = __salt__["config.option"]("s3.service_url")333 if not service_url:334 service_url = "s3.amazonaws.com"335 if verify_ssl is None and __salt__["config.option"]("s3.verify_ssl") is not None:336 verify_ssl = __salt__["config.option"]("s3.verify_ssl")337 if verify_ssl is None:338 verify_ssl = True339 if location is None and __salt__["config.option"]("s3.location") is not None:340 location = __salt__["config.option"]("s3.location")341 if role_arn is None and __salt__["config.option"]("s3.role_arn"):342 role_arn = __salt__["config.option"]("s3.role_arn")343 if path_style is None and __salt__["config.option"]("s3.path_style") is not None:344 path_style = __salt__["config.option"]("s3.path_style")345 if path_style is None:346 path_style = False347 if (348 https_enable is None349 and __salt__["config.option"]("s3.https_enable") is not None350 ):351 https_enable = __salt__["config.option"]("s3.https_enable")352 if https_enable is None:353 https_enable = True354 return (355 key,356 keyid,357 service_url,358 verify_ssl,359 kms_keyid,360 location,361 role_arn,362 path_style,363 https_enable,...

Full Screen

Full Screen

simple_encoding_live_job_s3_role_based_credentials.py

Source:simple_encoding_live_job_s3_role_based_credentials.py Github

copy

Full Screen

...39 'use_external_id': 'useExternalId'40 })41 return attributes42 @property43 def role_arn(self):44 # type: () -> string_types45 """Gets the role_arn of this SimpleEncodingLiveJobS3RoleBasedCredentials.46 Amazon ARN of the IAM Role (Identity and Access Management Role) that will be assumed for S3 access. More details can be found [here](https://bitmovin.com/docs/encoding/api-reference/sections/inputs#/Encoding/PostEncodingInputsS3RoleBased) (required)47 :return: The role_arn of this SimpleEncodingLiveJobS3RoleBasedCredentials.48 :rtype: string_types49 """50 return self._role_arn51 @role_arn.setter52 def role_arn(self, role_arn):53 # type: (string_types) -> None54 """Sets the role_arn of this SimpleEncodingLiveJobS3RoleBasedCredentials.55 Amazon ARN of the IAM Role (Identity and Access Management Role) that will be assumed for S3 access. More details can be found [here](https://bitmovin.com/docs/encoding/api-reference/sections/inputs#/Encoding/PostEncodingInputsS3RoleBased) (required)56 :param role_arn: The role_arn of this SimpleEncodingLiveJobS3RoleBasedCredentials.57 :type: string_types58 """59 if role_arn is not None:60 if not isinstance(role_arn, string_types):61 raise TypeError("Invalid type for `role_arn`, type has to be `string_types`")62 self._role_arn = role_arn63 @property64 def use_external_id(self):65 # type: () -> bool66 """Gets the use_external_id of this SimpleEncodingLiveJobS3RoleBasedCredentials....

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful