title: how can i create S3 Lifecycle configuration using Terraform?
body: <p>I tried to use newer_noncurrent_versions in S3 Lifecycle.</p>
  <p>In <a href="https://github.com/hashicorp/terraform-provider-aws/releases/tag/v4.3.0" rel="nofollow noreferrer">Terraform 4.3.0</a>, lifecycle was released.</p>
  <p>However, when applying on Terraform cloud, an error saying to use Lifecycle V2 occurred.</p>
  <p>Is my code the problem? Is it a terraform provider problem?</p>
  <h3>Terraform CLI and Terraform AWS Provider Version</h3>
  <pre><code>Terraform v1.1.5
  on darwin_amd64
  </code></pre>
  <h3>Terraform Configuration Files</h3>
  <pre><code>resource &quot;aws_s3_bucket_lifecycle_configuration&quot; &quot;s3&quot; {
    bucket = &quot;aws-test-bucket&quot;
  
    rule {
      id     = &quot;rule&quot;
      status = &quot;Enabled&quot;
  
      noncurrent_version_expiration {
        noncurrent_days                  = 1
        newer_noncurrent_versions = 2
      }
    }
  }
  </code></pre>
  <h3>Actual Behavior</h3>
  <ul>
  <li>When I run <code>terrafrom plan</code> on local, it seems to be created just fine.</li>
  </ul>
  <pre><code>  + resource &quot;aws_s3_bucket_lifecycle_configuration&quot; &quot;s3&quot; {
        + bucket = (known after apply)
        + id     = (known after apply)
  
        + rule {
            + id     = &quot;rule&quot;
            + status = &quot;Enabled&quot;
  
            + noncurrent_version_expiration {
                + newer_noncurrent_versions = 2
                + noncurrent_days                  = 1
              }
          }
      }
  </code></pre>
  <p><strong>However, when applying in Terraform Cloud, the following error occurs.</strong></p>
  <pre><code>Error: error creating S3 Lifecycle Configuration for bucket (aws-test-bucket): InvalidRequest: 
  NewerNoncurrentVersions element can only be used in Lifecycle V2. 
  status code: 400, with aws_s3_bucket_lifecycle_configuration.s3
  on s3.tf line 66, in resource &quot;aws_s3_bucket_lifecycle_configuration&quot; &quot;s3&quot;:
  </code></pre>