templates/automationdocuments/AWSQuickstart-ActiveDirectoryDS.yaml [260:350]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- name: "configDC2"
  action: aws:runCommand
  onFailure: "step:signalfailure"
  nextStep: "DnsConfig"
  inputs:
    DocumentName: AWS-RunPowerShellScript
    InstanceIds: 
      - "{{dc2InstanceId.InstanceId}}"
    CloudWatchOutputConfig:
      CloudWatchOutputEnabled: "true"
      CloudWatchLogGroupName: !Ref 'QuickStartLogs'
    Parameters:
      commands: 
        - |     
           function DscStatusCheck () {
               $LCMState = (Get-DscLocalConfigurationManager).LCMState
               if ($LCMState -eq 'PendingConfiguration' -Or $LCMState -eq 'PendingReboot') {
                   'returning 3010, should continue after reboot'
                   exit 3010
               } else {
                   'Completed'
               }
           }
           
           Start-DscConfiguration 'C:\AWSQuickstart\ConfigDC2' -Wait -Verbose -Force
           
           DscStatusCheck
# Ensure that AD servers point to themselves for DNS
- name: "DnsConfig"
  action: "aws:runCommand"
  onFailure: "step:signalfailure"
  inputs:
    DocumentName: "AWS-RunRemoteScript"
    InstanceIds:
      - "{{dc2InstanceId.InstanceId}}"
    CloudWatchOutputConfig:
      CloudWatchOutputEnabled: "true"
      CloudWatchLogGroupName: !Ref 'QuickStartLogs'
    Parameters:
      sourceType: S3
      sourceInfo: 
        !Sub 
          - '{"path": "https://${S3Bucket}.s3.${S3Region}.{{URLSuffix}}/{{QSS3KeyPrefix}}scripts/Dns-Config.ps1"}'
          - S3Bucket: !If
              - UsingDefaultBucket
              - !Sub '${QSS3BucketName}-${AWS::Region}'
              - !Ref QSS3BucketName
            S3Region: !If 
              - UsingDefaultBucket
              - !Ref AWS::Region
              - !Ref QSS3BucketRegion
      commandLine: "./Dns-Config.ps1 -ADServer1NetBIOSName {{ADServer1NetBIOSName}} -ADServer2NetBIOSName {{ADServer2NetBIOSName}} -ADServer1PrivateIP {{ADServer1PrivateIP}} -ADServer2PrivateIP {{ADServer2PrivateIP}} -DomainDNSName {{DomainDNSName}} -ADAdminSecParam {{ADAdminSecParamName}}"
# Determines if CFN Needs to be Signaled or if Work flow should just end
- name: CFNSignalEnd
  action: aws:branch
  inputs:
    Choices:
    - NextStep: signalsuccess
      Not: 
        Variable: "{{StackName}}"
        StringEquals: ""
    - NextStep: sleepend
      Variable: "{{StackName}}"
      StringEquals: ""
# If all steps complete successfully signals CFN of Success
- name: "signalsuccess"
  action: "aws:executeAwsApi"
  isEnd: True
  inputs:
    Service: cloudformation
    Api: SignalResource
    LogicalResourceId: "DomainController2"
    StackName: "{{StackName}}"
    Status: SUCCESS
    UniqueId: "{{dc2InstanceId.InstanceId}}"
# If CFN Signl Not Needed this sleep ends work flow
- name: "sleepend"
  action: "aws:sleep"
  isEnd: True
  inputs:
    Duration: PT1S
# If any steps fails signals CFN of Failure
- name: "signalfailure"
  action: "aws:executeAwsApi"
  inputs:
    Service: cloudformation
    Api: SignalResource
    LogicalResourceId: "DomainController2"
    StackName: "{{StackName}}"
    Status: FAILURE
    UniqueId: "{{dc2InstanceId.InstanceId}}"
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



templates/automationdocuments/AWSQuickstart-extendAD.yaml [260:350]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- name: "configDC2"
  action: aws:runCommand
  onFailure: "step:signalfailure"
  nextStep: "DnsConfig"
  inputs:
    DocumentName: AWS-RunPowerShellScript
    InstanceIds: 
      - "{{dc2InstanceId.InstanceId}}"
    CloudWatchOutputConfig:
      CloudWatchOutputEnabled: "true"
      CloudWatchLogGroupName: !Ref 'QuickStartLogs'
    Parameters:
      commands: 
        - |     
           function DscStatusCheck () {
               $LCMState = (Get-DscLocalConfigurationManager).LCMState
               if ($LCMState -eq 'PendingConfiguration' -Or $LCMState -eq 'PendingReboot') {
                   'returning 3010, should continue after reboot'
                   exit 3010
               } else {
                   'Completed'
               }
           }
           
           Start-DscConfiguration 'C:\AWSQuickstart\ConfigDC2' -Wait -Verbose -Force
           
           DscStatusCheck
# Ensure that AD servers point to themselves for DNS
- name: "DnsConfig"
  action: "aws:runCommand"
  onFailure: "step:signalfailure"
  inputs:
    DocumentName: "AWS-RunRemoteScript"
    InstanceIds:
      - "{{dc2InstanceId.InstanceId}}"
    CloudWatchOutputConfig:
      CloudWatchOutputEnabled: "true"
      CloudWatchLogGroupName: !Ref 'QuickStartLogs'
    Parameters:
      sourceType: S3
      sourceInfo: 
        !Sub 
          - '{"path": "https://${S3Bucket}.s3.${S3Region}.{{URLSuffix}}/{{QSS3KeyPrefix}}scripts/Dns-Config.ps1"}'
          - S3Bucket: !If
              - UsingDefaultBucket
              - !Sub '${QSS3BucketName}-${AWS::Region}'
              - !Ref QSS3BucketName
            S3Region: !If 
              - UsingDefaultBucket
              - !Ref AWS::Region
              - !Ref QSS3BucketRegion
      commandLine: "./Dns-Config.ps1 -ADServer1NetBIOSName {{ADServer1NetBIOSName}} -ADServer2NetBIOSName {{ADServer2NetBIOSName}} -ADServer1PrivateIP {{ADServer1PrivateIP}} -ADServer2PrivateIP {{ADServer2PrivateIP}} -DomainDNSName {{DomainDNSName}} -ADAdminSecParam {{ADAdminSecParamName}}"
# Determines if CFN Needs to be Signaled or if Work flow should just end
- name: CFNSignalEnd
  action: aws:branch
  inputs:
    Choices:
    - NextStep: signalsuccess
      Not: 
        Variable: "{{StackName}}"
        StringEquals: ""
    - NextStep: sleepend
      Variable: "{{StackName}}"
      StringEquals: ""
# If all steps complete successfully signals CFN of Success
- name: "signalsuccess"
  action: "aws:executeAwsApi"
  isEnd: True
  inputs:
    Service: cloudformation
    Api: SignalResource
    LogicalResourceId: "DomainController2"
    StackName: "{{StackName}}"
    Status: SUCCESS
    UniqueId: "{{dc2InstanceId.InstanceId}}"
# If CFN Signl Not Needed this sleep ends work flow
- name: "sleepend"
  action: "aws:sleep"
  isEnd: True
  inputs:
    Duration: PT1S
# If any steps fails signals CFN of Failure
- name: "signalfailure"
  action: "aws:executeAwsApi"
  inputs:
    Service: cloudformation
    Api: SignalResource
    LogicalResourceId: "DomainController2"
    StackName: "{{StackName}}"
    Status: FAILURE
    UniqueId: "{{dc2InstanceId.InstanceId}}"
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



