Example #1
0
File: rds.py Project: Knewton/k.aws
def connect(creds):
	"""
	Connect to RDS, with user-provided options.

	:param region_creds: The region name and AWS credentials.
	:type region_creds: k.aws.config.AwsCreds or k.aws.config.RegionAwsCreds

	:rtype: boto.rds.RDSConnection
	"""
	if isinstance(creds, AwsCreds):
		return boto.connect_rds(**connection_hash(creds))
	elif isinstance(creds, RegionAwsCreds):
		return boto.rds.connect_to_region(**region_connection_hash(creds))
	raise Exception("Unrecognized credential type: %s" % creds)
Example #2
0
File: iam.py Project: Knewton/k.aws
def connect(creds):
	"""
	Connect to autoscale, with user-provided options.

	:param region_creds: The region name and AWS credentials.
	:type region_creds: k.aws.config.AwsCreds or k.aws.config.RegionAwsCreds

	:rtype: boto.iam.connection.IAMConnection

	Note IAM cannot authenticate a user using STS credentials."""
	if isinstance(creds, AwsCreds):
		return boto.connect_iam(**connection_hash(creds))
	elif isinstance(creds, RegionAwsCreds):
		return boto.iam.connect_to_region(
			**region_connection_hash(creds))
	raise Exception("Unrecognized credential type: %s" % creds)
Example #3
0
File: s3.py Project: Knewton/k.aws
def connect(creds, bucket_name=None, ordinary=False):
    """
	Connect to s3 using a k.aws.config.AwsCreds named tuple
	"""
    kwargs = {}
    if ordinary:
        kwargs["calling_format"] = OrdinaryCallingFormat()
    if bucket_name and not is_valid_dns_name(bucket_name):
        kwargs["calling_format"] = OrdinaryCallingFormat()
    if isinstance(creds, AwsCreds):
        kwargs.update(connection_hash(creds))
    elif isinstance(creds, RegionAwsCreds):
        kwargs.update(region_connection_hash(creds))
        del kwargs["region_name"]

    conn = boto.connect_s3(**kwargs)
    return conn