I have a power shell script which reads the lifecycle policy using
lifecycleConfig = aws s3api get-bucket-lifecycle-configuration –bucket $bucketName
It returns the lifecycle policy but when there is no lifecycle policy it is returning error
An error occurred (NoSuchLifecycleConfiguration) when calling the GetBucketLifecycleConfiguration operation: The lifecycle configuration does not exist
and it runs into the next block of code.
So if my lifecycleConfig is null I dont want any error printing i want it to run next step
where i will add the new lifecycle policy.
please help me to remove the error if the lifecycle is not present.
3