Skip to content

Commit

Permalink
Merge pull request #5850 from gazoakley/f-ssm-session-documents
Browse files Browse the repository at this point in the history
resource/aws_ssm_document: Add support for Session document_type
  • Loading branch information
bflad committed Sep 12, 2018
2 parents bf04624 + 4515d55 commit 8a237d4
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
1 change: 1 addition & 0 deletions aws/resource_aws_ssm_document.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func resourceAwsSsmDocument() *schema.Resource {
ssm.DocumentTypeCommand,
ssm.DocumentTypePolicy,
ssm.DocumentTypeAutomation,
ssm.DocumentTypeSession,
}, false),
},
"schema_version": {
Expand Down
42 changes: 42 additions & 0 deletions aws/resource_aws_ssm_document_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,25 @@ func TestAccAWSSSMDocument_automation(t *testing.T) {
})
}

func TestAccAWSSSMDocument_session(t *testing.T) {
name := acctest.RandString(10)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSSSMDocumentDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSSSMDocumentTypeSessionConfig(name),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSSSMDocumentExists("aws_ssm_document.foo"),
resource.TestCheckResourceAttr(
"aws_ssm_document.foo", "document_type", "Session"),
),
},
},
})
}

func TestAccAWSSSMDocument_DocumentFormat_YAML(t *testing.T) {
name := acctest.RandString(10)
content1 := `
Expand Down Expand Up @@ -639,6 +658,29 @@ DOC
`, rName, rName, rName)
}

func testAccAWSSSMDocumentTypeSessionConfig(rName string) string {
return fmt.Sprintf(`
resource "aws_ssm_document" "foo" {
name = "test_document-%s"
document_type = "Session"
content = <<DOC
{
"schemaVersion": "1.0",
"description": "Document to hold regional settings for Session Manager",
"sessionType": "Standard_Stream",
"inputs": {
"s3BucketName": "test",
"s3KeyPrefix": "test",
"s3EncryptionEnabled": true,
"cloudWatchLogGroupName": "/logs/sessions",
"cloudWatchEncryptionEnabled": false
}
}
DOC
}
`, rName)
}

func testAccAWSSSMDocumentConfig_DocumentFormat_YAML(rName, content string) string {
return fmt.Sprintf(`
resource "aws_ssm_document" "foo" {
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 @@ -50,7 +50,7 @@ The following arguments are supported:
* `name` - (Required) The name of the document.
* `content` - (Required) The JSON or YAML content of the document.
* `document_format` - (Optional, defaults to JSON) The format of the document. Valid document types include: `JSON` and `YAML`
* `document_type` - (Required) The type of the document. Valid document types include: `Command`, `Policy` and `Automation`
* `document_type` - (Required) The type of the document. Valid document types include: `Command`, `Policy`, `Automation` and `Session`
* `permissions` - (Optional) Additional Permissions to attach to the document. See [Permissions](#permissions) below for details.
* `tags` - (Optional) A mapping of tags to assign to the object.

Expand Down

0 comments on commit 8a237d4

Please sign in to comment.