Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

F aws bedrock custom model #34310

Merged
merged 64 commits into from
Feb 2, 2024

Conversation

skyscrapr
Copy link
Contributor

Description

add aws_bedrock_custom_model resource and datasources

Relations

Relates #34148
Closes #33718

References

https://docs.aws.amazon.com/bedrock/latest/APIReference/API_CreateModelCustomizationJob.html
https://docs.aws.amazon.com/bedrock/latest/APIReference/API_GetCustomModel.html
https://docs.aws.amazon.com/bedrock/latest/APIReference/API_DeleteCustomModel.html

Output from Acceptance Testing

% make testacc TESTS=TestAccBedrockCustomModel_ PKG=bedrock

TBD...

Copy link

github-actions bot commented Nov 8, 2023

Community Note

Voting for Prioritization

  • Please vote on this pull request by adding a 👍 reaction to the original post to help the community and maintainers prioritize this pull request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

For Submitters

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added size/XL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. tags Pertains to resource tagging. generators Relates to code generators. service/bedrock Issues and PRs that pertain to the bedrock service. labels Nov 8, 2023
@terraform-aws-provider terraform-aws-provider bot added needs-triage Waiting for first response or review from a maintainer. partner Contribution from a partner. labels Nov 8, 2023
@justinretzolk justinretzolk added new-resource Introduces a new resource. and removed needs-triage Waiting for first response or review from a maintainer. labels Nov 8, 2023
@skyscrapr
Copy link
Contributor Author

@wellsiau-aws @AdamTylerLynch Can you get this tested please? I no longer have an account with access to the Titan Express preview model required to test fine-tuning.

@silvaalbert
Copy link
Contributor

@wellsiau-aws @AdamTylerLynch Can you get this tested please? I no longer have an account with access to the Titan Express preview model required to test fine-tuning.

I'll run these today

@silvaalbert
Copy link
Contributor

@skyscrapr - I was able to run tests but am getting failures. See below. Happy to collaborate on fixes if you like.

TF_ACC=1 go test ./internal/service/bedrock/... -v -count 1 -parallel 5 -run='TestAccBedrockCustomModelDataSource'  -timeout 360m
=== RUN   TestAccBedrockCustomModelDataSource_basic
=== PAUSE TestAccBedrockCustomModelDataSource_basic
=== CONT  TestAccBedrockCustomModelDataSource_basic
    custom_model_data_source_test.go:21: Step 1/1 error: Error running apply: exit status 1

        Error: Provider returned invalid result object after apply

        After the apply operation, the provider still indicated an unknown value for
        aws_bedrock_custom_model.test.base_model_arn. All values must be known after
        apply, so this is always a bug in the provider and should be reported in the
        provider's own repository. Terraform will still save the other known object
        values in the state.

        Error: Provider returned invalid result object after apply

        After the apply operation, the provider still indicated an unknown value for
        aws_bedrock_custom_model.test.creation_time. All values must be known after
        apply, so this is always a bug in the provider and should be reported in the
        provider's own repository. Terraform will still save the other known object
        values in the state.

        Error: Provider returned invalid result object after apply

        After the apply operation, the provider still indicated an unknown value for
        aws_bedrock_custom_model.test.model_arn. All values must be known after
        apply, so this is always a bug in the provider and should be reported in the
        provider's own repository. Terraform will still save the other known object
        values in the state.

        Error: Provider returned invalid result object after apply

        After the apply operation, the provider still indicated an unknown value for
        aws_bedrock_custom_model.test.model_kms_key_arn. All values must be known
        after apply, so this is always a bug in the provider and should be reported
        in the provider's own repository. Terraform will still save the other known
        object values in the state.

        Error: Provider returned invalid result object after apply

        After the apply operation, the provider still indicated an unknown value for
        aws_bedrock_custom_model.test.model_name. All values must be known after
        apply, so this is always a bug in the provider and should be reported in the
        provider's own repository. Terraform will still save the other known object
        values in the state.

        Error: Provider returned invalid result object after apply

        After the apply operation, the provider still indicated an unknown value for
        aws_bedrock_custom_model.test.tags_all. All values must be known after apply,
        so this is always a bug in the provider and should be reported in the
        provider's own repository. Terraform will still save the other known object
        values in the state.

        Error: Value Conversion Error

          with aws_bedrock_custom_model.test,
          on terraform_plugin_test.tf line 123, in resource "aws_bedrock_custom_model" "test":
         123: resource "aws_bedrock_custom_model" "test" {

        An unexpected error was encountered trying to convert from value. This is
        always an error in the provider. Please report the following to the provider
        developer:

        cannot use type bedrock.validationDataConfig as schema type
        basetypes.ListType; basetypes.ListType must be an attr.TypeWithAttributeTypes
        to hold bedrock.validationDataConfig
--- FAIL: TestAccBedrockCustomModelDataSource_basic (3873.56s)
FAIL
FAIL	github.com/hashicorp/terraform-provider-aws/internal/service/bedrock	3876.854s
FAIL
make: *** [testacc] Error 1

@skyscrapr
Copy link
Contributor Author

@silvaalbert ... hi, thanks for the output. Let me take a look at this today and I'll confirm if we need to connect to resolve.

@AdamTylerLynch
Copy link
Collaborator

@skyscrapr can you please contact me directly? awstyler [@] amazon.com

@AdamTylerLynch
Copy link
Collaborator

Current outputs:

make testacc TESTS=TestAccBedrockCustomModel_ PKG=bedrock
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/bedrock/... -v -count 1 -parallel 20 -run='TestAccBedrockCustomModel_'  -timeout 360m
=== RUN   TestAccBedrockCustomModel_basic
=== PAUSE TestAccBedrockCustomModel_basic
=== CONT  TestAccBedrockCustomModel_basic
    custom_model_test.go:20: Step 1/2 error: Error running apply: exit status 1
        
        Error: Provider produced inconsistent result after apply
        
        When applying changes to aws_bedrock_custom_model.test, provider
        "provider[\"registry.terraform.io/hashicorp/aws\"]" produced an unexpected
        new value: .training_metrics: block count changed from 0 to 1.
        
        This is a bug in the provider, which should be reported in the provider's own
        issue tracker.
--- FAIL: TestAccBedrockCustomModel_basic (4369.05s)
FAIL
FAIL	github.com/hashicorp/terraform-provider-aws/internal/service/bedrock	4372.322s
FAIL
make: *** [testacc] Error 1

% make testacc TESTARGS='-run=TestAccBedrockCustomModel_validationDataConfig' PKG=bedrock
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/bedrock/... -v -count 1 -parallel 20  -run=TestAccBedrockCustomModel_validationDataConfig -timeout 360m
=== RUN   TestAccBedrockCustomModel_validationDataConfig
=== PAUSE TestAccBedrockCustomModel_validationDataConfig
=== CONT  TestAccBedrockCustomModel_validationDataConfig
--- PASS: TestAccBedrockCustomModel_validationDataConfig (39.58s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/bedrock	50.791s
% make testacc TESTARGS='-run=TestAccBedrockCustomModel_kmsKey' PKG=bedrock
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/bedrock/... -v -count 1 -parallel 20  -run=TestAccBedrockCustomModel_kmsKey -timeout 360m
=== RUN   TestAccBedrockCustomModel_kmsKey
=== PAUSE TestAccBedrockCustomModel_kmsKey
=== CONT  TestAccBedrockCustomModel_kmsKey
--- PASS: TestAccBedrockCustomModel_kmsKey (49.63s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/bedrock	60.146s
@ewbankkit
Copy link
Contributor

ewbankkit commented Feb 1, 2024

After a design discussion with @AdamTylerLynch, we decided on this resource lifecycle:

This Terraform resource interacts with two Amazon Bedrock entities:

  1. A Continued Pre-training or Fine-tuning job which is started when the Terraform resource is created. The customization job can take several hours to run to completion. The duration of the job depends on the size of the training data (number of records, input tokens, and output tokens), and hyperparameters (number of epochs, and batch size).
  2. The custom model output on successful completion of the customization job.

This resource's behaviors correspond to operations on these Amazon Bedrock entities:

  • Create starts the customization job and immediately returns.
  • Read returns the status and results of the customization job. If the customization job has completed, the output model's properties are returned.
  • Update updates the customization job's tags.
  • Delete stops the customization job if it is still active. If the customization job has completed, the custom model output by the job is deleted.

@skyscrapr
Copy link
Contributor Author

@ewbankkit @AdamTylerLynch Hey gents. Apologies for dropping this. The customer I was working with put this on hold end of last year. I've been away for all of January and AFK. I'm back on the ground from Monday. Thanks for picking this up. Let me know if there's more to do, and I can continue to work on this.

Copy link
Contributor

@ewbankkit ewbankkit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀.

% make testacc TESTARGS='-run=TestAccBedrockCustomModel_validationDataConfigWaitForCompletion' PKG=bedrock
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/bedrock/... -v -count 1 -parallel 20  -run=TestAccBedrockCustomModel_validationDataConfigWaitForCompletion -timeout 360m
=== RUN   TestAccBedrockCustomModel_validationDataConfigWaitForCompletion
=== PAUSE TestAccBedrockCustomModel_validationDataConfigWaitForCompletion
=== CONT  TestAccBedrockCustomModel_validationDataConfigWaitForCompletion
--- PASS: TestAccBedrockCustomModel_validationDataConfigWaitForCompletion (4376.29s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/bedrock	4389.235s
% make testacc TESTARGS='-run=TestAccBedrockFoundationModel' PKG=bedrock ACCTEST_PARALLELISM=2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/bedrock/... -v -count 1 -parallel 2  -run=TestAccBedrockFoundationModel -timeout 360m
=== RUN   TestAccBedrockFoundationModelDataSource_basic
=== PAUSE TestAccBedrockFoundationModelDataSource_basic
=== RUN   TestAccBedrockFoundationModelsDataSource_basic
=== PAUSE TestAccBedrockFoundationModelsDataSource_basic
=== RUN   TestAccBedrockFoundationModelsDataSource_byCustomizationType
=== PAUSE TestAccBedrockFoundationModelsDataSource_byCustomizationType
=== RUN   TestAccBedrockFoundationModelsDataSource_byInferenceType
=== PAUSE TestAccBedrockFoundationModelsDataSource_byInferenceType
=== RUN   TestAccBedrockFoundationModelsDataSource_byOutputModality
=== PAUSE TestAccBedrockFoundationModelsDataSource_byOutputModality
=== CONT  TestAccBedrockFoundationModelDataSource_basic
=== CONT  TestAccBedrockFoundationModelsDataSource_byInferenceType
--- PASS: TestAccBedrockFoundationModelsDataSource_byInferenceType (14.20s)
=== CONT  TestAccBedrockFoundationModelsDataSource_byOutputModality
--- PASS: TestAccBedrockFoundationModelDataSource_basic (14.41s)
=== CONT  TestAccBedrockFoundationModelsDataSource_byCustomizationType
--- PASS: TestAccBedrockFoundationModelsDataSource_byCustomizationType (13.11s)
=== CONT  TestAccBedrockFoundationModelsDataSource_basic
--- PASS: TestAccBedrockFoundationModelsDataSource_byOutputModality (13.34s)
--- PASS: TestAccBedrockFoundationModelsDataSource_basic (11.82s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/bedrock	50.205s
% make testacc-short TESTARGS='-run=TestAccBedrockCustomModel_' PKG=bedrock ACCTEST_PARALLELISM=1   
==> Checking that code complies with gofmt requirements...
Running acceptance tests with -short flag
TF_ACC=1 go test ./internal/service/bedrock/... -v -short -count 1 -parallel 1  -run=TestAccBedrockCustomModel_ -timeout 360m
=== RUN   TestAccBedrockCustomModel_basic
=== PAUSE TestAccBedrockCustomModel_basic
=== RUN   TestAccBedrockCustomModel_disappears
=== PAUSE TestAccBedrockCustomModel_disappears
=== RUN   TestAccBedrockCustomModel_tags
=== PAUSE TestAccBedrockCustomModel_tags
=== RUN   TestAccBedrockCustomModel_kmsKey
=== PAUSE TestAccBedrockCustomModel_kmsKey
=== RUN   TestAccBedrockCustomModel_validationDataConfig
=== PAUSE TestAccBedrockCustomModel_validationDataConfig
=== RUN   TestAccBedrockCustomModel_validationDataConfigWaitForCompletion
    custom_model_test.go:209: skipping long-running test in short mode
--- SKIP: TestAccBedrockCustomModel_validationDataConfigWaitForCompletion (0.00s)
=== RUN   TestAccBedrockCustomModel_vpcConfig
=== PAUSE TestAccBedrockCustomModel_vpcConfig
=== CONT  TestAccBedrockCustomModel_basic
--- PASS: TestAccBedrockCustomModel_basic (60.77s)
=== CONT  TestAccBedrockCustomModel_kmsKey
--- PASS: TestAccBedrockCustomModel_kmsKey (59.36s)
=== CONT  TestAccBedrockCustomModel_vpcConfig
--- PASS: TestAccBedrockCustomModel_vpcConfig (56.68s)
=== CONT  TestAccBedrockCustomModel_validationDataConfig
--- PASS: TestAccBedrockCustomModel_validationDataConfig (58.70s)
=== CONT  TestAccBedrockCustomModel_tags
--- PASS: TestAccBedrockCustomModel_tags (57.94s)
=== CONT  TestAccBedrockCustomModel_disappears
--- PASS: TestAccBedrockCustomModel_disappears (76.31s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/bedrock	380.208s
% make testacc TESTARGS='-run=TestAccBedrockCustomModelDataSource_basic' PKG=bedrock
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/bedrock/... -v -count 1 -parallel 20  -run=TestAccBedrockCustomModelDataSource_basic -timeout 360m
=== RUN   TestAccBedrockCustomModelDataSource_basic
=== PAUSE TestAccBedrockCustomModelDataSource_basic
=== CONT  TestAccBedrockCustomModelDataSource_basic
--- PASS: TestAccBedrockCustomModelDataSource_basic (4298.45s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/bedrock	4309.648s
% make testacc TESTARGS='-run=TestAccBedrockCustomModelsDataSource_basic' PKG=bedrock
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/bedrock/... -v -count 1 -parallel 20  -run=TestAccBedrockCustomModelsDataSource_basic -timeout 360m
=== RUN   TestAccBedrockCustomModelsDataSource_basic
=== PAUSE TestAccBedrockCustomModelsDataSource_basic
=== CONT  TestAccBedrockCustomModelsDataSource_basic
--- PASS: TestAccBedrockCustomModelsDataSource_basic (4046.60s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/bedrock	4057.208s

@ewbankkit
Copy link
Contributor

@skyscrapr @AdamTylerLynch Thanks for the contribution 🎉 👏.

@ewbankkit ewbankkit merged commit a316669 into hashicorp:main Feb 2, 2024
43 checks passed
@github-actions github-actions bot added this to the v5.35.0 milestone Feb 2, 2024
Copy link

github-actions bot commented Feb 2, 2024

This functionality has been released in v5.35.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!

Copy link

github-actions bot commented Mar 4, 2024

I'm going to lock this pull request 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 related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
generators Relates to code generators. new-data-source Introduces a new data source. new-resource Introduces a new resource. partner Contribution from a partner. prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. service/bedrock Issues and PRs that pertain to the bedrock service. size/XL Managed by automation to categorize the size of a PR. tags Pertains to resource tagging. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[New Resource]: aws_bedrock_model_customization_job
5 participants