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.81k stars 9.16k forks source link

[Enhancement]: Support for all AWS FIS Action targets #35299

Closed ebarros29 closed 9 months ago

ebarros29 commented 9 months ago

Description

AWS FIS has support for many Action targets according to it's documentation, however the aws_fis_experiment_template resource does not support the below action targets:

Error message after executing terraform plan:

╷
│ Error: expected action.0.target.0.key to be one of ["Cluster" "Clusters" "DBInstances" "Instances" "Nodegroups" "Pods" "Roles" "SpotInstances" "Subnets" "Tasks" "Volumes"], got Tables
│ 
│   with aws_fis_experiment_template.example,
│   on main.tf line 1, in resource "aws_fis_experiment_template" "example":
│    1: resource "aws_fis_experiment_template" "example" {
│ 
╵
╷
│ Error: expected action.1.target.0.key to be one of ["Cluster" "Clusters" "DBInstances" "Instances" "Nodegroups" "Pods" "Roles" "SpotInstances" "Subnets" "Tasks" "Volumes"], got AutoScalingGroups
│ 
│   with aws_fis_experiment_template.example,
│   on main.tf line 1, in resource "aws_fis_experiment_template" "example":
│    1: resource "aws_fis_experiment_template" "example" {
│ 
╵
╷
│ Error: expected action.2.target.0.key to be one of ["Cluster" "Clusters" "DBInstances" "Instances" "Nodegroups" "Pods" "Roles" "SpotInstances" "Subnets" "Tasks" "Volumes"], got ReplicationGroups
│ 
│   with aws_fis_experiment_template.example,
│   on main.tf line 1, in resource "aws_fis_experiment_template" "example":
│    1: resource "aws_fis_experiment_template" "example" {
│ 
╵
╷
│ Error: expected action.3.target.0.key to be one of ["Cluster" "Clusters" "DBInstances" "Instances" "Nodegroups" "Pods" "Roles" "SpotInstances" "Subnets" "Tasks" "Volumes"], got TransitGateways
│ 
│   with aws_fis_experiment_template.example,
│   on main.tf line 1, in resource "aws_fis_experiment_template" "example":
│    1: resource "aws_fis_experiment_template" "example" {
│ 
╵
╷
│ Error: expected action.4.target.0.key to be one of ["Cluster" "Clusters" "DBInstances" "Instances" "Nodegroups" "Pods" "Roles" "SpotInstances" "Subnets" "Tasks" "Volumes"], got Buckets
│ 
│   with aws_fis_experiment_template.example,
│   on main.tf line 1, in resource "aws_fis_experiment_template" "example":
│    1: resource "aws_fis_experiment_template" "example" {
│ 
╵

Affected Resource(s) and/or Data Source(s)

Potential Terraform Configuration

resource "aws_fis_experiment_template" "test" {
  description = "test-experiment-template"
  role_arn    = var.fis_iam_role_arn

  stop_condition {
    source = "none"
  }

  action {
    name      = "asg-action"
    action_id = "aws:ec2:asg-insufficient-instance-capacity-error"

    parameter {
      key = "duration"
      value = "PT5M"
    }

    parameter {
      key = "availabilityZoneIdentifiers"
      value = "use1-az2"
    }

    target {
      key   = "AutoScalingGroups"
      value = "AutoScalingGroups-Target-2"
    }
  }

  action {
    name      = "bucket-action"
    action_id = "aws:s3:bucket-pause-replication"

    parameter {
      key = "duration"
      value = "PT5M"
    }

    parameter {
      key = "region"
      value = "eu-south-1"
    }

    target {
      key   = "Buckets"
      value = "Buckets-Target-4"
    }
  }

  action {
    name      = "dynamodb-action"
    action_id = "aws:dynamodb:encrypted-global-table-pause-replication"

    parameter {
      key = "duration"
      value = "PT5M"
    }

    target {
      key   = "Tables"
      value = "Tables-Target-3"
    }
  }

  action {
    name      = "elasticache-action"
    action_id = "aws:elasticache:interrupt-cluster-az-power"

    parameter {
      key = "duration"
      value = "PT5M"
    }

    target {
      key   = "ReplicationGroups"
      value = "ReplicationGroups-Target-5"
    }
  }

  action {
    name      = "tgw-action"
    action_id = "aws:network:transit-gateway-disrupt-cross-region-connectivity"

    parameter {
      key = "duration"
      value = "PT5M"
    }

    parameter {
      key = "region"
      value = "eu-south-1"
    }

    target {
      key   = "TransitGateways"
      value = "TransitGateways-Target-1"
    }
  }

  target {
    name           = "AutoScalingGroups-Target-2"
    resource_type  = "aws:ec2:autoscaling-group"
    selection_mode = "ALL"

    resource_tag {
      key   = "env"
      value = "example"
    }
  }

  target {
    name           = "Buckets-Target-4"
    resource_type  = "aws:s3:bucket"
    selection_mode = "ALL"

    resource_tag {
      key   = "env"
      value = "example"
    }
  }

  target {
    name           = "ReplicationGroups-Target-5"
    resource_type  = "aws:elasticache:redis-replicationgroup"
    selection_mode = "ALL"

    parameters = {
      availabilityZoneIdentifier = "us-east-1a"
    }

    resource_tag {
      key   = "env"
      value = "example"
    }
  }

  target {
    name           = "Tables-Target-3"
    resource_type  = "aws:dynamodb:encrypted-global-table"
    selection_mode = "ALL"

    resource_tag {
      key   = "env"
      value = "example"
    }
  }

  target {
    name           = "TransitGateways-Target-1"
    resource_type  = "aws:ec2:transit-gateway"
    selection_mode = "ALL"

    resource_tag {
      key   = "env"
      value = "example"
    }
  }

  tags = {
    Name = "test-experiment-template"
  }
}

References

Would you like to implement a fix?

Yes

github-actions[bot] commented 9 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

github-actions[bot] commented 9 months ago

This functionality has been released in v5.34.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

github-actions[bot] commented 8 months ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.