Skip to content

Commit

Permalink
resource/aws_ssm_document: Support in-place version_name updates, add…
Browse files Browse the repository at this point in the history
… CHANGELOG entry for #14128

Output from acceptance testing in AWS Commercial:

```
--- PASS: TestAccAWSSSMDocument_params (30.50s)
--- PASS: TestAccAWSSSMDocument_basic (32.24s)
--- PASS: TestAccAWSSSMDocument_session (32.29s)
--- PASS: TestAccAWSSSMDocument_permission_private (32.51s)
--- PASS: TestAccAWSSSMDocument_permission_batching (32.78s)
--- PASS: TestAccAWSSSMDocument_permission_public (32.80s)
--- PASS: TestAccAWSSSMDocument_automation (37.50s)
--- PASS: TestAccAWSSSMDocument_VersionName (46.97s)
--- PASS: TestAccAWSSSMDocument_DocumentFormat_YAML (46.99s)
--- PASS: TestAccAWSSSMDocument_target_type (48.06s)
--- PASS: TestAccAWSSSMDocument_update (48.17s)
--- PASS: TestAccAWSSSMDocument_SchemaVersion_1 (48.20s)
--- PASS: TestAccAWSSSMDocument_Tags (57.02s)
--- PASS: TestAccAWSSSMDocument_permission_change (57.33s)
--- PASS: TestAccAWSSSMDocument_package (73.74s)
```

Output from acceptance testing in AWS GovCloud (US):

```
--- PASS: TestAccAWSSSMDocument_basic (34.86s)
--- PASS: TestAccAWSSSMDocument_session (39.41s)
--- PASS: TestAccAWSSSMDocument_params (39.84s)
--- PASS: TestAccAWSSSMDocument_permission_private (40.26s)
--- PASS: TestAccAWSSSMDocument_permission_public (40.37s)
--- PASS: TestAccAWSSSMDocument_permission_batching (40.94s)
--- PASS: TestAccAWSSSMDocument_automation (52.65s)
--- PASS: TestAccAWSSSMDocument_target_type (54.33s)
--- PASS: TestAccAWSSSMDocument_update (55.65s)
--- PASS: TestAccAWSSSMDocument_DocumentFormat_YAML (55.72s)
--- PASS: TestAccAWSSSMDocument_VersionName (55.79s)
--- PASS: TestAccAWSSSMDocument_SchemaVersion_1 (55.96s)
--- PASS: TestAccAWSSSMDocument_Tags (66.39s)
--- PASS: TestAccAWSSSMDocument_permission_change (68.28s)
--- PASS: TestAccAWSSSMDocument_package (80.15s)
```
  • Loading branch information
bflad committed Feb 12, 2021
1 parent 8ce6d55 commit bbae8ed
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .changelog/14128.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_ssm_document: Add `version_name` argument
```
6 changes: 4 additions & 2 deletions aws/resource_aws_ssm_document.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,6 @@ func resourceAwsSsmDocument() *schema.Resource {
"version_name": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
},
},
}
Expand Down Expand Up @@ -658,6 +656,10 @@ func updateAwsSSMDocument(d *schema.ResourceData, meta interface{}) error {
updateDocInput.TargetType = aws.String(v.(string))
}

if v, ok := d.GetOk("version_name"); ok {
updateDocInput.VersionName = aws.String(v.(string))
}

if d.HasChange("attachments_source") {
updateDocInput.Attachments = expandSsmAttachmentsSources(d.Get("attachments_source").([]interface{}))
}
Expand Down
9 changes: 5 additions & 4 deletions aws/resource_aws_ssm_document_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func TestAccAWSSSMDocument_basic(t *testing.T) {
testAccCheckResourceAttrRfc3339(resourceName, "created_date"),
resource.TestCheckResourceAttr(resourceName, "tags.%", "0"),
resource.TestCheckResourceAttrSet(resourceName, "document_version"),
resource.TestCheckResourceAttr(resourceName, "version_name", ""),
),
},
{
Expand Down Expand Up @@ -72,7 +73,7 @@ func TestAccAWSSSMDocument_target_type(t *testing.T) {
})
}

func TestAccAWSSSMDocument_version_name(t *testing.T) {
func TestAccAWSSSMDocument_VersionName(t *testing.T) {
name := acctest.RandString(10)
resourceName := "aws_ssm_document.test"
resource.ParallelTest(t, resource.TestCase{
Expand Down Expand Up @@ -659,14 +660,14 @@ DOC
func testAccAWSSSMDocumentBasicConfigVersionName(rName, version string) string {
return fmt.Sprintf(`
resource "aws_ssm_document" "test" {
name = "%s"
name = %[1]q
document_type = "Command"
version_name = "%s"
version_name = %[2]q
content = <<DOC
{
"schemaVersion": "2.0",
"description": "Sample version 2.0 document v2",
"description": "Sample version 2.0 document %[2]s",
"parameters": {
},
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/ssm_document.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ The following arguments are supported:
* `document_type` - (Required) The type of the document. Valid document types include: `Automation`, `Command`, `Package`, `Policy`, and `Session`
* `permissions` - (Optional) Additional Permissions to attach to the document. See [Permissions](#permissions) below for details.
* `target_type` - (Optional) The target type which defines the kinds of resources the document can run on. For example, /AWS::EC2::Instance. For a list of valid resource types, see AWS Resource Types Reference (http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html)
* `version_name` - (Optional) A field specifying the version of the artifact you are creating with the document. For example, "Release 12, Update 6"
* `tags` - (Optional) A map of tags to assign to the object.
* `version_name` - (Optional) A field specifying the version of the artifact you are creating with the document. For example, "Release 12, Update 6". This value is unique across all versions of a document and cannot be changed for an existing document version.

## attachments_source

Expand Down

0 comments on commit bbae8ed

Please sign in to comment.