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.86k stars 9.2k forks source link

[Bug]: Medialive STANDARD Channel creation fails in AZ inconsistency #40003

Open arielsalvo opened 3 weeks ago

arielsalvo commented 3 weeks ago

Terraform Core Version

1.9.2

AWS Provider Version

5.74.0

Affected Resource(s)

aws_medialive_input aws_medialive_channel

Expected Behavior

AWS Medialive Channel created as specified in the docs.

Actual Behavior

aws_medialive_channel.channel: Creating...
╷
│ Error: creating AWS Elemental MediaLive Channel (ml-test-01): operation error MediaLive: CreateChannel, https response error StatusCode: 400, RequestID: ************, BadRequestException: There is an Availability Zone conflict in one or both channel pipelines. Probably you have VPC inputs in this channel, and those inputs are in a different Availability Zone from the subnets that you specified for the channel endpoints. Verify the Availability Zones of your VPC inputs and VPC endpoints, and try again.
│ 
│   with aws_medialive_channel.channel,
│   on main.tf line 36, in resource "aws_medialive_channel" "channel":
│   36: resource "aws_medialive_channel" "channel" {
│ 
╵

Relevant Error/Panic Output Snippet

aws_medialive_channel.channel: Creating...
╷
│ Error: creating AWS Elemental MediaLive Channel (ml-test-01): operation error MediaLive: CreateChannel, https response error StatusCode: 400, RequestID: **********, BadRequestException: There is an Availability Zone conflict in one or both channel pipelines. Probably you have VPC inputs in this channel, and those inputs are in a different Availability Zone from the subnets that you specified for the channel endpoints. Verify the Availability Zones of your VPC inputs and VPC endpoints, and try again.
│ 
│   with aws_medialive_channel.channel,
│   on main.tf line 36, in resource "aws_medialive_channel" "channel":
│   36: resource "aws_medialive_channel" "channel" {
│ 
╵

Terraform Configuration Files

terraform {
  required_version = "1.9.2"
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "5.74.0"
    }
  }
}

variable "stack_name" { type = string }
variable "security_group_ids" { type = list(string) }
variable "subnet_ids" { type = list(string) }
variable "role_arn" { type = string }
variable "s3_url" { type = string }

resource "aws_medialive_input" "input" {
  name = var.stack_name
  type = "RTMP_PUSH"

  role_arn = var.role_arn

  destinations {
    stream_name = "${var.stack_name}/0"
  }
  destinations {
    stream_name = "${var.stack_name}/1"
  }

  vpc {
    security_group_ids = toset(var.security_group_ids)
    subnet_ids         = toset(var.subnet_ids)
  }
}

resource "aws_medialive_channel" "channel" {
  name          = var.stack_name
  channel_class = "STANDARD"
  role_arn      = var.role_arn

  start_channel = false

  input_specification {
    codec            = "AVC"
    input_resolution = "HD"
    maximum_bitrate  = "MAX_20_MBPS"
  }

  input_attachments {
    input_attachment_name = var.stack_name
    input_id              = aws_medialive_input.input.id
  }

  destinations {
    id = "S3"
    settings {
      url = "${var.s3_url}/dest1"
    }
    settings {
      url = "${var.s3_url}/dest2"
    }
  }

  encoder_settings {
    timecode_config {
      source = "SYSTEMCLOCK"
    }
    video_descriptions {
      name = "v1"
    }

    output_groups {
      output_group_settings {
        archive_group_settings {
          destination {
            destination_ref_id = "S3"
          }
        }
      }

      outputs {
        output_name             = "o1"
        video_description_name  = "v1"
        output_settings {
          archive_output_settings {
            name_modifier = "_1"
            extension     = "m2ts"
            container_settings {
              m2ts_settings {
                audio_buffer_model = "ATSC"
                buffer_model       = "MULTIPLEX"
                rate_mode          = "CBR"
              }
            }
          }
        }
      }
    }
  }

  maintenance {
    maintenance_day        = "MONDAY"
    maintenance_start_time = "03:00"
  }
  vpc {
    public_address_allocation_ids = []
    security_group_ids            = toset(var.security_group_ids)
    subnet_ids                    = toset(var.subnet_ids)
  }
}

Steps to Reproduce

Create a VPC with 2 private subnets, a role with the appropriate permissions for Medialive, and an S3 bucket. Create a terraform.tfvars file with the required variable values. Execute a terraform apply (the error does not appear during the planning stage)

Debug Output

I am not able to share this info.

Panic Output

No response

Important Factoids

The Medialive Input is created without issue but the Channel fails to create with this AZ inconsistency error even though the subnets are exactly the same and in the same order. I have been able to create the channel via the console or the CLI and then import this channel into the terraform code without issues. Subsequent plans after the import will not detect any pending change.

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 3 weeks ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue