AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.
Write-S3LifecycleConfiguration-BucketName <String>-ChecksumAlgorithm <ChecksumAlgorithm>-ExpectedBucketOwner <String>-Configuration_Rule <LifecycleRule[]>-Select <String>-PassThru <SwitchParameter>-Force <SwitchParameter>-ClientConfig <AmazonS3Config>-UseAccelerateEndpoint <SwitchParameter>-UseDualstackEndpoint <SwitchParameter>-ForcePathStyleAddressing <Boolean>
Required? | False |
Position? | 1 |
Accept pipeline input? | True (ByValue, ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | Configuration_Rules |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | AK |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByValue, ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByValue, ByPropertyName) |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | AWSProfilesLocation, ProfilesLocation |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | StoredCredentials, AWSProfileName |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | RegionToCall |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | SK, SecretAccessKey |
Required? | False |
Position? | Named |
Accept pipeline input? | True (ByPropertyName) |
Aliases | ST |
$NewRule = [Amazon.S3.Model.LifecycleRule] @{
Expiration = @{
Days= 50
}
Id = "Test-From-Write-cmdlet-1"
Filter= @{
LifecycleFilterPredicate = [Amazon.S3.Model.LifecycleAndOperator]@{
Operands= @(
[Amazon.S3.Model.LifecyclePrefixPredicate] @{
"Prefix" = "py"
},
[Amazon.S3.Model.LifecycleTagPredicate] @{
"Tag"= @{
"Key" = "non-use"
"Value" = "yes"
}
}
)
}
}
"Status"= 'Enabled'
NoncurrentVersionExpiration = @{
NoncurrentDays = 75
}
}
Write-S3LifecycleConfiguration -BucketName my-review-scrap -Configuration_Rule $NewRuleThis example writes / replaces the configuration provided in the $NewRule. This configuration is making sure to limit the scope objects with given prefix and tag values.
$ExpireRule = [Amazon.S3.Model.LifecycleRule] @{
Expiration = @{
Days= 150
}
Id = "Remove-in-150-days"
Filter= @{
LifecycleFilterPredicate = [Amazon.S3.Model.LifecycleAndOperator]@{
Operands= @(
[Amazon.S3.Model.LifecyclePrefixPredicate] @{
"Prefix" = "py"
},
[Amazon.S3.Model.LifecycleTagPredicate] @{
"Tag"= @{
"Key" = "archived"
"Value" = "yes"
}
}
)
}
}
Status= 'Enabled'
NoncurrentVersionExpiration = @{
NoncurrentDays = 150
}
}
$ArchiveRule = [Amazon.S3.Model.LifecycleRule] @{
Expiration = $null
Id = "Archive-to-Glacier-in-30-days"
Filter= @{
LifecycleFilterPredicate = [Amazon.S3.Model.LifecycleAndOperator]@{
Operands= @(
[Amazon.S3.Model.LifecyclePrefixPredicate] @{
"Prefix" = "py"
},
[Amazon.S3.Model.LifecycleTagPredicate] @{
"Tag"= @{
"Key" = "reviewed"
"Value" = "yes"
}
}
)
}
}
Status = 'Enabled'
NoncurrentVersionExpiration = @{
NoncurrentDays = 75
}
Transitions = @(
@{
Days = 30
"StorageClass"= 'Glacier'
},
@{
Days = 120
"StorageClass"= [Amazon.S3.S3StorageClass]::DeepArchive
}
)
}
Write-S3LifecycleConfiguration -BucketName my-review-scrap -Configuration_Rule $ExpireRule,$ArchiveRuleThis example sets multiple rules with filtering. $ArchiveRule sets the objects to archive in 30 days to Glacier and 120 to DeepArchive. $ExpireRule expires both current and previous versions in 150 days for objects with 'py' prefix and tag:key 'archieved' set to 'yes'.
AWS Tools for PowerShell: 2.x.y.z