Last active
March 8, 2019 05:48
-
-
Save scrthq/b9e90747e1ed218634619f2373a4ee4d to your computer and use it in GitHub Desktop.
VaporShell Snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Recreation of the example found here: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ssm-document.html | |
$ssmDocContent = [PSCustomObject]@{ | |
schemaVersion = "1.2" | |
description = "Join instances to an AWS Directory Service domain." | |
parameters = @{ | |
directoryId = @{ | |
type = "String" | |
description = "(Required) The ID of the AWS Directory Service directory." | |
} | |
directoryName = @{ | |
type = "String" | |
description = "(Required) The name of the directory; for example, test.example.com" | |
} | |
dnsIpAddresses = @{ | |
type = "StringList" | |
default = @() | |
description = "(Optional) The IP addresses of the DNS servers in the directory. Required when DHCP is not configured. Learn more at http://docs.aws.amazon.com/directoryservice/latest/simple-ad/join_get_dns_addresses.html" | |
allowedPattern = "((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" | |
} | |
} | |
runtimeConfig = @{ | |
"aws:domainJoin" = @{ | |
properties = @{ | |
directoryId = "{{ directoryId }}" | |
directoryName = "{{ directoryName }}" | |
dnsIpAddresses = "{{ dnsIpAddresses }}" | |
} | |
} | |
} | |
} | |
$template = Initialize-Vaporshell -Description "AWS Domain Join SSM Doc" | |
$ssmDoc = New-VSSSMDocument -LogicalId 'document' -Content $ssmDocContent | |
$template.AddResource($ssmDoc) | |
$template.ToJson() # Creates the JSON string template seen below | |
$template.ToYaml() # Creates the YAML string template seen below (if cfn-flip is installed) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"AWSTemplateFormatVersion": "2010-09-09", | |
"Description": "Testing SSM docs", | |
"Resources": { | |
"document": { | |
"Type": "AWS::SSM::Document", | |
"Properties": { | |
"Content": { | |
"schemaVersion": "1.2", | |
"description": "Join instances to an AWS Directory Service domain.", | |
"parameters": { | |
"dnsIpAddresses": { | |
"allowedPattern": "((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)", | |
"description": "(Optional) The IP addresses of the DNS servers in the directory. Required when DHCP is not configured. Learn more at http://docs.aws.amazon.com/directoryservice/latest/simple-ad/join_get_dns_addresses.html", | |
"default": [ | |
], | |
"type": "StringList" | |
}, | |
"directoryName": { | |
"type": "String", | |
"description": "(Required) The name of the directory; for example, test.example.com" | |
}, | |
"directoryId": { | |
"type": "String", | |
"description": "(Required) The ID of the AWS Directory Service directory." | |
} | |
}, | |
"runtimeConfig": { | |
"aws:domainJoin": { | |
"properties": { | |
"dnsIpAddresses": "{{ dnsIpAddresses }}", | |
"directoryName": "{{ directoryName }}", | |
"directoryId": "{{ directoryId }}" | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: '2010-09-09' | |
Description: Testing SSM docs | |
Resources: | |
document: | |
Type: AWS::SSM::Document | |
Properties: | |
Content: | |
schemaVersion: '1.2' | |
description: Join instances to an AWS Directory Service domain. | |
parameters: | |
dnsIpAddresses: | |
allowedPattern: ((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?) | |
description: >- | |
(Optional) The IP addresses of the DNS servers in the directory. Required | |
when DHCP is not configured. Learn more at http://docs.aws.amazon.com/directoryservice/latest/simple-ad/join_get_dns_addresses.html | |
default: [] | |
type: StringList | |
directoryName: | |
type: String | |
description: (Required) The name of the directory; for example, test.example.com | |
directoryId: | |
type: String | |
description: (Required) The ID of the AWS Directory Service directory. | |
runtimeConfig: | |
aws:domainJoin: | |
properties: | |
dnsIpAddresses: '{{ dnsIpAddresses }}' | |
directoryName: '{{ directoryName }}' | |
directoryId: '{{ directoryId }}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ssmDocContent = [PSCustomObject]@{ | |
schemaVersion = "1.2" | |
description = "Join instances to an AWS Directory Service domain." | |
parameters = @{ | |
directoryId = @{ | |
type = "String" | |
description = "(Required) The ID of the AWS Directory Service directory." | |
} | |
directoryName = @{ | |
type = "String" | |
description = "(Required) The name of the directory; for example, test.example.com" | |
} | |
dnsIpAddresses = @{ | |
type = "StringList" | |
default = @() | |
description = "(Optional) The IP addresses of the DNS servers in the directory. Required when DHCP is not configured. Learn more at http://docs.aws.amazon.com/directoryservice/latest/simple-ad/join_get_dns_addresses.html" | |
allowedPattern = "((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" | |
} | |
} | |
runtimeConfig = @{ | |
"aws:domainJoin" = @{ | |
properties = @{ | |
directoryId = "{{ directoryId }}" | |
directoryName = "{{ directoryName }}" | |
dnsIpAddresses = "{{ dnsIpAddresses }}" | |
} | |
} | |
} | |
} | |
New-SSMDocument -Content ($ssmDocContent | ConvertTo-Json -Depth 10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is for schema 1.2, this can easily be modified thanks to your work to 2.2 schema. Just need to figure out if I use AWSPowershell to then upload to AWS or vaporshell has a "publish" type of command for the doc.