From 2c78ef7c48ffa0cf34727e84362fbd81f5273aa6 Mon Sep 17 00:00:00 2001 From: Lorenz Vanthillo Date: Tue, 2 Dec 2025 21:22:10 +0100 Subject: [PATCH 1/3] feat: support changecalender integration in aws_ssm_association --- .changelog/45318.txt | 3 +++ internal/service/ssm/association.go | 17 +++++++++++++++++ internal/service/ssm/association_test.go | 3 +++ 3 files changed, 23 insertions(+) create mode 100644 .changelog/45318.txt diff --git a/.changelog/45318.txt b/.changelog/45318.txt new file mode 100644 index 000000000000..0077d5f2d2a3 --- /dev/null +++ b/.changelog/45318.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/aws_ssm_association: Add `calendar_names` argument +``` diff --git a/internal/service/ssm/association.go b/internal/service/ssm/association.go index dc56a89a5acc..a20355d0b9ad 100644 --- a/internal/service/ssm/association.go +++ b/internal/service/ssm/association.go @@ -23,6 +23,7 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/enum" "github.com/hashicorp/terraform-provider-aws/internal/errs" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" + "github.com/hashicorp/terraform-provider-aws/internal/flex" tfmaps "github.com/hashicorp/terraform-provider-aws/internal/maps" tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" @@ -72,6 +73,13 @@ func resourceAssociation() *schema.Resource { Optional: true, ValidateFunc: validation.StringLenBetween(1, 50), }, + "calendar_names": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, "compliance_severity": { Type: schema.TypeString, Optional: true, @@ -191,6 +199,10 @@ func resourceAssociationCreate(ctx context.Context, d *schema.ResourceData, meta input.AutomationTargetParameterName = aws.String(v.(string)) } + if v, ok := d.GetOk("calendar_names"); ok && v.(*schema.Set).Len() > 0 { + input.CalendarNames = flex.ExpandStringValueSet(v.(*schema.Set)) + } + if v, ok := d.GetOk("compliance_severity"); ok { input.ComplianceSeverity = awstypes.AssociationComplianceSeverity(v.(string)) } @@ -273,6 +285,7 @@ func resourceAssociationRead(ctx context.Context, d *schema.ResourceData, meta a d.Set(names.AttrAssociationID, association.AssociationId) d.Set("association_name", association.AssociationName) d.Set("automation_target_parameter_name", association.AutomationTargetParameterName) + d.Set("calendar_names", association.CalendarNames) d.Set("compliance_severity", association.ComplianceSeverity) d.Set("document_version", association.DocumentVersion) d.Set("max_concurrency", association.MaxConcurrency) @@ -315,6 +328,10 @@ func resourceAssociationUpdate(ctx context.Context, d *schema.ResourceData, meta input.AutomationTargetParameterName = aws.String(v.(string)) } + if v, ok := d.GetOk("calendar_names"); ok && v.(*schema.Set).Len() > 0 { + input.CalendarNames = flex.ExpandStringValueSet(v.(*schema.Set)) + } + if v, ok := d.GetOk("compliance_severity"); ok { input.ComplianceSeverity = awstypes.AssociationComplianceSeverity(v.(string)) } diff --git a/internal/service/ssm/association_test.go b/internal/service/ssm/association_test.go index 1cb9b2abe1cd..ad854a6db963 100644 --- a/internal/service/ssm/association_test.go +++ b/internal/service/ssm/association_test.go @@ -36,6 +36,7 @@ func TestAccSSMAssociation_basic(t *testing.T) { testAccCheckAssociationExists(ctx, resourceName), acctest.MatchResourceAttrRegionalARN(ctx, resourceName, names.AttrARN, "ssm", regexache.MustCompile(`association/.+`)), resource.TestCheckResourceAttr(resourceName, "apply_only_at_cron_interval", acctest.CtFalse), + resource.TestCheckResourceAttr(resourceName, "calendar_names.#", "0"), resource.TestCheckResourceAttr(resourceName, "output_location.#", "0"), resource.TestCheckResourceAttr(resourceName, "targets.#", "1"), resource.TestCheckResourceAttr(resourceName, "targets.0.key", "InstanceIds"), @@ -1642,3 +1643,5 @@ resource "aws_ssm_association" "test" { } `) } + + From ef2d7ef745c3325435f950637959071a67c537fd Mon Sep 17 00:00:00 2001 From: Lorenz Vanthillo Date: Tue, 2 Dec 2025 21:43:50 +0100 Subject: [PATCH 2/3] fix: linter issues --- internal/service/ssm/association_test.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/internal/service/ssm/association_test.go b/internal/service/ssm/association_test.go index ad854a6db963..cb217a390c07 100644 --- a/internal/service/ssm/association_test.go +++ b/internal/service/ssm/association_test.go @@ -1643,5 +1643,3 @@ resource "aws_ssm_association" "test" { } `) } - - From 3b5016be1d5c9c1d4f1b2775fea4f0fd60876455 Mon Sep 17 00:00:00 2001 From: Lorenz Vanthillo Date: Tue, 2 Dec 2025 22:16:27 +0100 Subject: [PATCH 3/3] docs: update docs --- website/docs/r/ssm_association.html.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/website/docs/r/ssm_association.html.markdown b/website/docs/r/ssm_association.html.markdown index d1df3161a8b3..abfe57de19c9 100644 --- a/website/docs/r/ssm_association.html.markdown +++ b/website/docs/r/ssm_association.html.markdown @@ -251,6 +251,7 @@ This resource supports the following arguments: * `apply_only_at_cron_interval` - (Optional) By default, when you create a new or update associations, the system runs it immediately and then according to the schedule you specified. Enable this option if you do not want an association to run immediately after you create or update it. This parameter is not supported for rate expressions. Default: `false`. * `association_name` - (Optional) The descriptive name for the association. * `automation_target_parameter_name` - (Optional) Specify the target for the association. This target is required for associations that use an `Automation` document and target resources by using rate controls. This should be set to the SSM document `parameter` that will define how your automation will branch out. +* `calendar_names` - (Optional) One or more Systems Manager Change Calendar names. The association runs only when the Change Calendar is open. * `compliance_severity` - (Optional) The compliance severity for the association. Can be one of the following: `UNSPECIFIED`, `LOW`, `MEDIUM`, `HIGH` or `CRITICAL` * `document_version` - (Optional) The document version you want to associate with the target(s). Can be a specific version or the default version. * `max_concurrency` - (Optional) The maximum number of targets allowed to run the association at the same time. You can specify a number, for example 10, or a percentage of the target set, for example 10%.