Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
April 21, 2021 02:03 am GMT

EC2ADRunCommand

UserData

AWS Managed ADAD
Name

UserDataSystems Manager RunCommand

Systems ManagerSSMAmazonAMI



IAMAD



Systems ManagerCreate DocumentCommand or session

image



image



PowerShellYAML

---schemaVersion: "2.2"description: "Join AD and rename host with instance tag"parameters:  DomainName:    type: "String"    description: "ADDNS"  UserCredentialSecretID:    type: "String"    description: "ADSecrets ManagerID"  HostnameTag:    type: "String"    description: "Name"    default: "Name"mainSteps:- action: "aws:runPowerShellScript"  name: "example"  inputs:    runCommand:    - $secretManager = Get-SECSecretValue -SecretId {{UserCredentialSecretID}}    - $secret = $secretManager.SecretString | ConvertFrom-Json    - $username = $domainName + "\" + $secret.Account    - $password = $secret.Password | ConvertTo-SecureString -AsPlainText -Force    - $credential = New-Object System.Management.Automation.PSCredential($username,$password)    - $instanceID = Get-EC2InstanceMetadata -Category InstanceId    - $nameTag = Get-EC2Tag -Filter @{Name="resource-id";Value="$instanceID"},@{Name="key";Value="{{HostnameTag}}"}    - $newName = $nameTag.Value    - Add-Computer -DomainName "{{DomainName}}" -NewName "$newName" -Credential $credential -Passthru -Force -Restart

{{}}



Run CommandEC2

image



image

ChefOpsWorks




Computer vector created by macrovector - www.freepik.com


Original Link: https://dev.to/ryanch79/ec2-ad-runcommand-1b70

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To