hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.64k stars 9.01k forks source link

Add Elemental MediaStore Container Object Lifecycle Policy #12591

Open jfreeland opened 4 years ago

jfreeland commented 4 years ago

Community Note

Description

Add the ability to add, update, and remove object lifecycle policies to Elemental MediaStore containers.

New or Affected Resource(s)

Potential Terraform Configuration

resource "aws_media_store_container_lifecycle_policy" "lifecycle" {
  container_name = aws_media_store_container.example.name
  rules = [
    {
      prefix = [ "Football/", "Baseball/" ]
      days_since_create = { ">", 28 }
      action = "EXPIRE"
    },
    {
      prefix = [ "AwardsShow/" ]
      days_since_create = { ">=", 15 }
      action = "EXPIRE"
    },
    {
      prefix = [ "" ]
      days_since_create = { ">", 40 }
      action = "EXPIRE"
    },
    {
      wildcard = [ "Football/*.ts" ]
      days_since_create = { ">", 20 }
      action = "EXPIRE"
    },
    {
      wildcard = [ "Football/index*.m3u8" ]
      seconds_since_create = { ">", 15 }
      action = "EXPIRE"
    },
  ]
}

I'm sure there is room for improvement in the above example. It might also be reasonable to just include a raw policy, for example:

resource "aws_media_store_container_lifecycle_policy" "lifecycle" {
  container_name = aws_media_store_container.example.name
  rules = <<EOF
{        
    "rules": [
         {
            "definition": {
                "path": [ 
                    {"prefix": "Football/"}, 
                    {"prefix": "Baseball/"}
                ],
                "days_since_create": [
                    {"numeric": [">" , 28]}
                ]
            },
            "action": "EXPIRE"
        },
        {
            "definition": {
                "path": [ { "prefix": "AwardsShow/" }  ],
                "days_since_create": [
                    {"numeric": [">=" , 15]}
                ]
            },
            "action": "EXPIRE"
        },
        {
            "definition": {
                "path": [ { "prefix": "" }  ],
                "days_since_create": [
                    {"numeric": [">" , 40]}
                ]
            },
            "action": "EXPIRE"
        },
        {
            "definition": {
                "path": [ { "wildcard": "Football/*.ts" }  ],
                "days_since_create": [
                    {"numeric": [">" , 20]}
                ]
            },
            "action": "EXPIRE"
        },
        {
            "definition": {
                "path": [ 
                    {"wildcard": "Football/index*.m3u8"}
                ],
                "seconds_since_create": [
                    {"numeric": [">" , 15]}
                ]
            },
            "action": "EXPIRE"
        }
    ]
}
EOF
}

References

github-actions[bot] commented 1 year ago

Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label.

If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!