Skip to content

create_location_s3

create_location_s3(
    s3_bucket_arn: S3BucketArn,
    s3_config: S3Config,
    *,
    config_overrides: Optional[DataSyncClientConfig] = None,
    subdirectory: Optional[S3Subdirectory] = None,
    s3_storage_class: Optional[S3StorageClass] = None,
    agent_arns: Optional[AgentArnList] = None,
    tags: Optional[InputTagList] = None,
) -> CreateLocationS3Response

Creates a transfer location for an Amazon S3 bucket. DataSync can use this location as a source or destination for transferring data.

Before you begin, make sure that you read the following topics:

For more information, see Configuring transfers with Amazon S3.

Parameters:

  • subdirectory (Optional[S3Subdirectory], default: None ) –

    Specifies a prefix in the S3 bucket that DataSync reads from or writes to (depending on whether the bucket is a source or destination location).

    DataSync can't transfer objects with a prefix that begins with a slash (/) or includes //, /./, or /../ patterns. For example:

    • /photos

    • photos//2006/January

    • photos/./2006/February

    • photos/../2006/March

  • s3_bucket_arn (S3BucketArn) –

    Specifies the ARN of the S3 bucket that you want to use as a location. (When creating your DataSync task later, you specify whether this location is a transfer source or destination.)

    If your S3 bucket is located on an Outposts resource, you must specify an Amazon S3 access point. For more information, see Managing data access with Amazon S3 access points in the Amazon S3 User Guide.

  • s3_storage_class (Optional[S3StorageClass], default: None ) –

    Specifies the storage class that you want your objects to use when Amazon S3 is a transfer destination.

    For buckets in Amazon Web Services Regions, the storage class defaults to STANDARD. For buckets on Outposts, the storage class defaults to OUTPOSTS.

    For more information, see Storage class considerations with Amazon S3 transfers.

  • agent_arns (Optional[AgentArnList], default: None ) –

    (Amazon S3 on Outposts only) Specifies the Amazon Resource Name (ARN) of the DataSync agent on your Outpost.

    For more information, see Deploy your DataSync agent on Outposts.

  • tags (Optional[InputTagList], default: None ) –

    Specifies labels that help you categorize, filter, and search for your Amazon Web Services resources. We recommend creating at least a name tag for your transfer location.

Raises:

Source code in docs_src/capo_datasync/_services/data_sync.py
def create_location_s3(
    self,
    s3_bucket_arn: "capo_datasync.types.s3_bucket_arn.S3BucketArn",
    s3_config: "capo_datasync.types.s3_config.S3Config",
    *,
    config_overrides: Optional[DataSyncClientConfig] = None,
    subdirectory: Optional[
        "capo_datasync.types.s3_subdirectory.S3Subdirectory"
    ] = None,
    s3_storage_class: Optional[
        "capo_datasync.types.s3_storage_class.S3StorageClass"
    ] = None,
    agent_arns: Optional["capo_datasync.types.agent_arn_list.AgentArnList"] = None,
    tags: Optional["capo_datasync.types.input_tag_list.InputTagList"] = None,
) -> "capo_datasync.types.create_location_s3_response.CreateLocationS3Response":
    """<p>Creates a transfer <i>location</i> for an Amazon S3 bucket. DataSync can use this location as a source or destination for transferring data.</p> <important> <p>Before you begin, make sure that you read the following topics:</p> <ul> <li> <p> <a href="https://docs.aws.amazon.com/datasync/latest/userguide/create-s3-location.html#using-storage-classes">Storage class considerations with Amazon S3 locations</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/datasync/latest/userguide/create-s3-location.html#create-s3-location-s3-requests">Evaluating S3 request costs when using DataSync</a> </p> </li> </ul> </important> <p> For more information, see <a href="https://docs.aws.amazon.com/datasync/latest/userguide/create-s3-location.html">Configuring transfers with Amazon S3</a>.</p>

    Args:
        subdirectory: <p>Specifies a prefix in the S3 bucket that DataSync reads from or writes to (depending on whether the bucket is a source or destination location).</p> <note> <p>DataSync can't transfer objects with a prefix that begins with a slash (<code>/</code>) or includes <code>//</code>, <code>/./</code>, or <code>/../</code> patterns. For example:</p> <ul> <li> <p> <code>/photos</code> </p> </li> <li> <p> <code>photos//2006/January</code> </p> </li> <li> <p> <code>photos/./2006/February</code> </p> </li> <li> <p> <code>photos/../2006/March</code> </p> </li> </ul> </note>
        s3_bucket_arn: <p>Specifies the ARN of the S3 bucket that you want to use as a location. (When creating your DataSync task later, you specify whether this location is a transfer source or destination.) </p> <p>If your S3 bucket is located on an Outposts resource, you must specify an Amazon S3 access point. For more information, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-points.html">Managing data access with Amazon S3 access points</a> in the <i>Amazon S3 User Guide</i>.</p>
        s3_storage_class: <p>Specifies the storage class that you want your objects to use when Amazon S3 is a transfer destination.</p> <p>For buckets in Amazon Web Services Regions, the storage class defaults to <code>STANDARD</code>. For buckets on Outposts, the storage class defaults to <code>OUTPOSTS</code>.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/datasync/latest/userguide/create-s3-location.html#using-storage-classes">Storage class considerations with Amazon S3 transfers</a>.</p>
        agent_arns: <p>(Amazon S3 on Outposts only) Specifies the Amazon Resource Name (ARN) of the DataSync agent on your Outpost.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/datasync/latest/userguide/deploy-agents.html#outposts-agent">Deploy your DataSync agent on Outposts</a>.</p>
        tags: <p>Specifies labels that help you categorize, filter, and search for your Amazon Web Services resources. We recommend creating at least a name tag for your transfer location.</p>

    Raises:
        capo_datasync.errors.internal_exception.InternalException: <p>This exception is thrown when an error occurs in the DataSync service.</p>
        capo_datasync.errors.invalid_request_exception.InvalidRequestException: <p>This exception is thrown when the client submits a malformed request.</p>
        capo_datasync.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_datasync.types.create_location_s3_request.CreateLocationS3Request]",
    ) -> OperationResponse[
        "capo_datasync.types.create_location_s3_response.CreateLocationS3Response"
    ]:
        import capo_datasync._operations.fmrs_service.create_location_s3

        output, http_response = (
            capo_datasync._operations.fmrs_service.create_location_s3.create_location_s3(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateLocationS3")
    )
    input_: capo_datasync.types.create_location_s3_request.CreateLocationS3Request = {
        "s3_bucket_arn": s3_bucket_arn,
        "s3_config": s3_config,
    }
    if subdirectory is not None:
        input_["subdirectory"] = subdirectory
    if s3_storage_class is not None:
        input_["s3_storage_class"] = s3_storage_class
    if agent_arns is not None:
        input_["agent_arns"] = agent_arns
    if tags is not None:
        input_["tags"] = tags

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output