Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/45318.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_ssm_association: Add `calendar_names` argument
```
17 changes: 17 additions & 0 deletions internal/service/ssm/association.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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))
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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))
}
Expand Down
1 change: 1 addition & 0 deletions internal/service/ssm/association_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/ssm_association.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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%.
Expand Down
Loading