-
Notifications
You must be signed in to change notification settings - Fork 669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
COS bucket: configuration of Archive and Expiraton policies #1590
Comments
lifemikey
changed the title
Cloud Object Storage bucket configuration of Archive and Expiraton policies
COS bucket: configuration of Archive and Expiraton policies
Jun 24, 2020
We are also looking for this functionality. |
as a workaround I've been using a null_resource: resource null_resource flowlogs_bucket_expiration {
triggers = {
bucket_id = ibm_cos_bucket.flowlogs_bucket.id
}
provisioner "local-exec" {
command = "./set_bucket_expiration.sh"
environment = {
ENDPOINT = "s3.${var.region}.cloud-object-storage.appdomain.cloud"
BUCKET=ibm_cos_bucket.flowlogs_bucket.bucket_name
API_KEY=ibm_resource_key.cos_key.credentials.apikey
}
}
} and #!/bin/sh
set -e
PAYLOAD="<LifecycleConfiguration>
<Rule>
<ID>expiration</ID>
<Status>Enabled</Status>
<Filter>
<Prefix/>
</Filter>
<Expiration>
<Days>1</Days>
</Expiration>
</Rule>
</LifecycleConfiguration>"
TOKEN=$(curl -X POST \
'https://iam.cloud.ibm.com/identity/token' \
-H 'content-type: application/x-www-form-urlencoded' \
-H 'accept: application/json' \
-d "grant_type=urn%3Aibm%3Aparams%3Aoauth%3Agrant-type%3Aapikey&apikey=$API_KEY")
PAYLOAD_MD5=$(echo -n "$PAYLOAD" | openssl dgst -r -md5 -binary | openssl enc -base64)
ACCESS_TOKEN=$(echo $TOKEN | jq -r .access_token)
curl -X PUT \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: text/plain" \
-H "Content-MD5: $PAYLOAD_MD5" \
--data "$PAYLOAD" \
https://$ENDPOINT/$BUCKET?lifecycle |
@l2fprod Thanks for pointing that out, I ve been using the same thing to remove default access policy (since I want only bucket access for the credentials, not whole cos) and did not thought about applying it to this case too. |
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ability to configure archive and expiration policies on the COS bucket with Terraform
Archive doc
https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-archive
Expiration doc
https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-expiry
Reference
https://bigblue.aha.io/features/OBJ-382
https://bigblue.aha.io/ideas/IDEA-I-3135
The text was updated successfully, but these errors were encountered: