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.63k stars 9.01k forks source link

[Bug]: aws_sagemaker_pipeline fails to update pipeline when using definition saved in S3 #38259

Open adamantike opened 1 week ago

adamantike commented 1 week ago

Terraform Core Version

1.4.7

AWS Provider Version

5.57.0

Affected Resource(s)

Expected Behavior

  1. SageMaker pipeline correctly updates to the new pipeline definition located in a different S3 file.
  2. pipeline_definition is not listed as a change in the diff, does not display that it will be changed to -> null

Actual Behavior

  1. The diff includes pipeline_definition changing from the current JSON definition to null.
  2. Apply fails, as it runs the validations for pipeline_definition (which is not being provided, as it's mutually exclusive with the pipeline_definition_s3_location attribute), indicating that its minimum length must be 1.

Relevant Error/Panic Output Snippet

# aws_sagemaker_pipeline.this will be updated in-place
  ~ resource "aws_sagemaker_pipeline" "this" {
        id                    = "mypipeline"
      - pipeline_definition   = jsonencode(
            {
              # all current JSON retrieved from the previous S3 file
            }
        ) -> null
      ~ pipeline_definition_s3_location {
          ~ object_key = "pipelines/0.0.1/mypipeline.json" -> "pipelines/0.0.2/mypipeline.json"
            # (1 unchanged attribute hidden)
        }
    }
Plan: 1 to add, 0 to change, 0 to destroy.
aws_sagemaker_pipeline.this: Modifying... [id=mypipeline]
╷
│ Error: updating SageMaker Pipeline (mypipeline): InvalidParameter: 1 validation error(s) found.
│ - minimum field size of 1, UpdatePipelineInput.PipelineDefinition.
│ 
│ 
│   with aws_sagemaker_pipeline.this,
│   on main.tf line 8, in resource "aws_sagemaker_pipeline" "this":
│    8: resource "aws_sagemaker_pipeline" "this" {
│ 
╵

Terraform Configuration Files

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.0"
    }
  }
}

provider "aws" {
  region = "us-east-1"
}

resource "aws_sagemaker_pipeline" "this" {
  pipeline_name         = "test"
  pipeline_display_name = "test"
  role_arn              = "<iam_role_arn>"

  pipeline_definition_s3_location {
    bucket     = "<s3_bucket_name>"
    object_key = "v1.json"
  }
}

Steps to Reproduce

  1. Upload two SageMaker pipeline JSON definitions to S3. Both can have the same content. (e.g. v1.json and v2.json)
  2. Run apply using v1.json to create the SageMaker pipeline.
  3. Change aws_sagemaker_pipeline.pipeline_definition_s3_location to point to v2.json.
  4. Try to apply, to update the pipeline to the new definition.

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 1 week ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue