0

When executing following command

aws s3api put-bucket-lifecycle --bucket krishna-s3auto --lifecycle-configuration '{"Rules":[{"Status":"Enabled","Prefix":"","Expiration":{"Days":'90'},"AbortIncompleteMultipartUpload":{"DaysAfterInitiation":'7'},"Transitions":[{"Days":'91'},"StorageClass":"STANDARD_IA"}],"ID":"Kittu"}]}'

I get the following error

Error parsing parameter '--lifecycle-configuration': Invalid JSON: Expecting ',' 
  delimiter: line 1 column 168 (char 167)
JSON received:
  {"Rules":[{"Status":"Enabled","Prefix":"","Expiration":{"Days":90},
   "AbortIncompleteMultipartUpload":{"DaysAfterInitiation":7},
   "Transitions":[{"Days":91},"StorageClass":"STANDARD_IA"}],"ID":"Kittu"}]}
0

1 Answer 1

3

Your JSON was malformed and as well had errors like 'Transitions' keyword was used instead of 'Transition'

Following command should solve your problem

aws s3api put-bucket-lifecycle --bucket sas3auto --lifecycle-configuration file://lifecycle.json

Following is what you need to put in the lifecycle.json file

{
  "Rules": [
    {
      "Status": "Enabled",
      "Prefix": "",
      "Expiration": {
        "Days": 90
      },
      "AbortIncompleteMultipartUpload": {
        "DaysAfterInitiation": 7
      },
      "Transition": {
          "Days": 91,
          "StorageClass": "STANDARD_IA"
      },
      "ID": "Kittu"
    }
  ]
}
Sign up to request clarification or add additional context in comments.

4 Comments

Hi Arafat, I tried this and its working.. but if i want to give the values as variable how can i do that in Json.
for example i tried this and its working good. #!/bin/bash days=$1 bucket_name=$2 echo 'days: $days' echo 'bucket name: $bucket_name' aws s3api put-bucket-lifecycle --bucket $bucket_name --lifecycle-configuration '{"Rules":[{"Status":"Enabled","Prefix":"","Expiration":{"Days":'$days'},"ID":"Kittu"}]}'
am running above mentioned script in ./s3lcyc.sh 91 s3auto
Hi @Ricky Vijay, if this or any answer has solved your question please consider accepting it by clicking the check-mark. This indicates to the wider community that you've found a solution and gives some reputation to both the answerer and yourself. There is no obligation to do this though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.