text 使用PowerShell创建AWS Systems Manager关联
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了text 使用PowerShell创建AWS Systems Manager关联相关的知识,希望对你有一定的参考价值。
$ProfileName = ''
$AWSRegion = 'us-west-2'
$AssociationName = 'MyAssociationName'
$ComplianceSeverity = [Amazon.SimpleSystemsManagement.AssociationComplianceSeverity]::MEDIUM
$MaxConcurrency = '10%'
$MaxError = '5%'
$ExecutionTimeoutInSeconds = '300'
$ScheduleExpression = 'rate(1 hour)'
$TargetTagKey = 'TagKey'
$TargetTagValues = @( 'TagValue' )
# DO THE WORK!
$scriptBlock = {
Write-Host 'Do some work!'
}
$target = [Amazon.SimpleSystemsManagement.Model.Target]::new()
$target.Key = 'tag:{0}' -f $TargetTagKey
$target.Values = $TargetTagValues
$auth = @{
ProfileName = $ProfileName
Region = $AWSRegion
}
$ssmAssociation = @{
AssociationName = $AssociationName
ComplianceSeverity = $ComplianceSeverity
MaxConcurrency = $MaxConcurrency
MaxError = $MaxError
Name = 'AWS-RunPowerShellScript'
Parameter = @{
commands = $scriptBlock.ToString()
executionTimeout = $ExecutionTimeoutInSeconds
}
ScheduleExpression = $ScheduleExpression
Target = @( $target )
}
$currentAssociation = Get-SSMAssociationList @auth | Where-Object {$_.AssociationName -eq $AssociationName}
if ($currentAssociation.AssociationId)
{
$null = Update-SSMAssociation -AssociationId $currentAssociation.AssociationId @ssmAssociation @auth
}
else
{
$null = New-SSMAssociation @ssmAssociation @auth
}
以上是关于text 使用PowerShell创建AWS Systems Manager关联的主要内容,如果未能解决你的问题,请参考以下文章
Powershell:使用临时凭证访问AWS s3存储桶
Powershell AWS 自动化管理 (11) - 创建一个高可用的WordPress博客(中)
text 使用Powershell创建
PowerShell AWS 自动化管理
Powershell AWS 自动化管理
AWS Lambda 自动化和 PowerShell