【執筆中】コードとかきれいにしてないけど現時点のメモ書きを載せておく
とりあえずセキュリティのパッチを取得してみる
public static async Task<string> SayHelloAsync([ActivityTrigger] string name, ILogger log)
{
//log.LogInformation($"Saying hello to {name}.");
var ssmClient = AwsSsmService.GetClient();
// Windows Server 2019
var request = new DescribeAvailablePatchesRequest();
var productFilter = new PatchOrchestratorFilter();
productFilter.Key = "PRODUCT";
productFilter.Values.Add("WindowsServer2019");
request.Filters.Add(productFilter);
var classificationFilter = new PatchOrchestratorFilter();
classificationFilter.Key = "CLASSIFICATION";
classificationFilter.Values.Add("SecurityUpdates");
request.Filters.Add(classificationFilter);
try
{
var response = await ssmClient.DescribeAvailablePatchesAsync(request);
string nextToken = null;
var patches = new List<Patch>();
int productCount = 0;
int repositoryCount = 0;
int savedProductCount = 0;
int savedRepositoryCount = 0;
if (response.HttpStatusCode == HttpStatusCode.OK)
{
do
{
Thread.Sleep(500);
nextToken = response.NextToken;
patches.AddRange(response.Patches);
var platformList = patches.Select(r => r.Product).Distinct();
productCount = platformList.Count();
var repositoryList = patches.Select(r => r.Repository).Distinct();
repositoryCount = repositoryList.Count();
} while (nextToken != null);
}
else
{
// Error
var code = response.HttpStatusCode;
}
// 2021/01のパッチだけ取得
var date = new DateTime(2021, 1, 1, 0, 0, 0, 0);
var currentPatches = patches.Where(r => r.ReleaseDate > date).ToList();
var temp = string.Empty;
return $"Hello {name}!";
}
catch (Exception ex)
{
var message = ex.Message;
throw;
}
}