[New Resource]: aws_marketplaceagreement_agreement
What new functionality are you requesting?
- Service: Marketplace Agreement (
marketplaceagreement) aws_marketplaceagreement_agreement
Description
Subscribing an account to an AWS Marketplace offer is a console-only step today, so an account can't be built from Terraform alone when it uses Marketplace products. The case that hit me is EKS add-ons from Marketplace: aws_eks_addon for datadog_operator fails with AddonSubscriptionNeeded about 15 minutes into a new cluster's first apply, until someone accepts the offer in that account's Marketplace console.
The Marketplace Agreement API supports this for buyers now. CreateAgreementRequest (intent NEW) returns a quote, and AcceptAgreementRequest turns it into an agreement. DescribeAgreement and GetAgreementTerms read it back, and CancelAgreement cancels it. The SDK has it as service/marketplaceagreement.
Plan, following the contributor guide:
- PR adding the
marketplaceagreementservice client. - PR adding
aws_marketplaceagreement_agreementand its list resource. Create isCreateAgreementRequest+AcceptAgreementRequest, Read isDescribeAgreement+GetAgreementTerms, Delete isCancelAgreement. Every argument change replaces the agreement. The identity isagreement_id.
What I found testing the API against a free offer (New Relic Kubernetes Operator):
CancelAgreementreturnsValidationExceptionwith reasonUNSUPPORTED_ACTIONfor about 80 seconds after the agreement is accepted, then succeeds. Delete has to retry.- An account can hold one active agreement per offer. A second
NEWrequest for the same offer fails withUNSUPPORTED_ACTION, so the acceptance tests have to run serially. DescribeAgreementreturns the offer ID but not the agreement proposal ID the agreement was created from, so an import can't fill inagreement_proposal_id.CancelAgreementon an agreement that's already cancelled succeeds.
AFAIK the acceptor can only cancel some agreements through the API (the buyer guide says usage agreements), so destroying a contract agreement will fail. That seems right to me: Terraform shouldn't be able to cancel a paid contract on its own.
Potential Terraform Configuration
# Datadog Operator EKS add-on (free)
resource "aws_marketplaceagreement_agreement" "datadog_operator" {
agreement_proposal_id = "at-6nuclnsh88uc2s8hs1mjzr5eu"
requested_term {
id = "term-331241c92e99c39ff990052b4ae78d0165d892136e6af1aee8d55b9c28b540f9" # LegalTerm
}
requested_term {
id = "term-17e763eebddabad9921f51d9360900fb6fd07cd91a0ab8699859b40d2cd7109a" # SupportTerm
}
}
resource "aws_eks_addon" "datadog_operator" {
cluster_name = aws_eks_cluster.example.name
addon_name = "datadog_operator"
depends_on = [aws_marketplaceagreement_agreement.datadog_operator]
}References
- Work with the Agreement API as a buyer
- CreateAgreementRequest
github.com/aws/aws-sdk-go-v2/service/marketplaceagreement
Would you like to implement the enhancement?
Yes
Source: hashicorp/terraform-provider-aws