[ aws . s3api ]

delete-object

Description

Removes the null version (if there is one) of an object and inserts a delete marker, which becomes the latest version of the object. If there isn’t a null version, Amazon S3 does not remove any objects.

To remove a specific version, you must be the bucket owner and you must use the version Id subresource. Using this subresource permanently deletes the version. If the object deleted is a delete marker, Amazon S3 sets the response header, x-amz-delete-marker , to true.

If the object you want to delete is in a bucket where the bucket versioning configuration is MFA Delete enabled, you must include the x-amz-mfa request header in the DELETE versionId request. Requests that include x-amz-mfa must use HTTPS.

For more information about MFA Delete, see Using MFA Delete . To see sample requests that use versioning, see Sample Request .

You can delete objects by explicitly calling DELETE Object or configure its lifecycle (PutBucketLifecycle ) to enable Amazon S3 to remove them for you. If you want to block users or accounts from removing or deleting objects from your bucket, you must deny them the s3:DeleteObject , s3:DeleteObjectVersion , and s3:PutLifeCycleConfiguration actions.

The following action is related to DeleteObject :

See also: AWS API Documentation

See ‘aws help’ for descriptions of global parameters.

Synopsis

  delete-object
--bucket <value>
--key <value>
[--mfa <value>]
[--version-id <value>]
[--request-payer <value>]
[--bypass-governance-retention | --no-bypass-governance-retention]
[--expected-bucket-owner <value>]
[--cli-input-json | --cli-input-yaml]
[--generate-cli-skeleton <value>]

Options

--bucket (string)

The bucket name of the bucket containing the object.

When using this action with an access point, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName -AccountId .s3-accesspoint.*Region* .amazonaws.com. When using this action with an access point through the AWS SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see Using Access Points in the Amazon Simple Storage Service Developer Guide .

When using this action with Amazon S3 on Outposts, you must direct requests to the S3 on Outposts hostname. The S3 on Outposts hostname takes the form AccessPointName -AccountId .*outpostID* .s3-outposts.*Region* .amazonaws.com. When using this action using S3 on Outposts through the AWS SDKs, you provide the Outposts bucket ARN in place of the bucket name. For more information about S3 on Outposts ARNs, see Using S3 on Outposts in the Amazon Simple Storage Service Developer Guide .

--key (string)

Key name of the object to delete.

--mfa (string)

The concatenation of the authentication device’s serial number, a space, and the value that is displayed on your authentication device. Required to permanently delete a versioned object if versioning is configured with MFA delete enabled.

--version-id (string)

VersionId used to reference a specific version of the object.

--request-payer (string)

Confirms that the requester knows that they will be charged for the request. Bucket owners need not specify this parameter in their requests. For information about downloading objects from requester pays buckets, see Downloading Objects in Requestor Pays Buckets in the Amazon S3 Developer Guide .

Possible values:

  • requester

--bypass-governance-retention | --no-bypass-governance-retention (boolean)

Indicates whether S3 Object Lock should bypass Governance-mode restrictions to process this operation.

--expected-bucket-owner (string)

The account id of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP 403 (Access Denied) error.

--cli-input-json | --cli-input-yaml (string) Reads arguments from the JSON string provided. The JSON string follows the format provided by --generate-cli-skeleton. If other arguments are provided on the command line, those values will override the JSON-provided values. It is not possible to pass arbitrary binary values using a JSON-provided value as the string will be taken literally. This may not be specified along with --cli-input-yaml.

--generate-cli-skeleton (string) Prints a JSON skeleton to standard output without sending an API request. If provided with no value or the value input, prints a sample input JSON that can be used as an argument for --cli-input-json. Similarly, if provided yaml-input it will print a sample input YAML that can be used with --cli-input-yaml. If provided with the value output, it validates the command inputs and returns a sample output JSON for that command.

See ‘aws help’ for descriptions of global parameters.

Examples

The following command deletes an object named test.txt from a bucket named my-bucket:

aws s3api delete-object --bucket my-bucket --key test.txt

If bucket versioning is enabled, the output will contain the version ID of the delete marker:

{
  "VersionId": "9_gKg5vG56F.TTEUdwkxGpJ3tNDlWlGq",
  "DeleteMarker": true
}

For more information about deleting objects, see Deleting Objects in the Amazon S3 Developer Guide.

Output

DeleteMarker -> (boolean)

Specifies whether the versioned object that was permanently deleted was (true) or was not (false) a delete marker.

VersionId -> (string)

Returns the version ID of the delete marker created as a result of the DELETE operation.

RequestCharged -> (string)

If present, indicates that the requester was successfully charged for the request.