以下是我创建lambda的方法:
final CreateFunctionRequest functionRequest = new CreateFunctionRequest();
request.withCode(code)
.withRole(assumedRole)
.withFunctionName(functionName);
final CreateFunctionResult functionResult = client.createFunction(functionRequest);
final String functionArn = result.getFunctionArn();
我想创建一个日志组并将其分配给它。这必须事先完成,否则AWS将自动分配日志组。这就是我到目前为止所做的:
final String logGroupName = // Create unique log name;
final CreateLogGroupRequest createRequest = new CreateLogGroupRequest(logGroupName);
final CreateLogGroupResult createResult = client.createLogGroup(createRequest);
final PutRetentionPolicyRequest retentionRequest = new PutRetentionPolicyRequest(logGroupName, 30);
final PutRetentionPolicyResult retentionResult = client.putRetentionPolicy(retentionRequest);
final PutResourcePolicyRequest resourceRequest = new PutResourcePolicyRequest();
// Don't know how to use this
// I want my functionArn to have access
我无法理解如何使用资源政策(我认为这就是我想要的?)。我试着看https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutResourcePolicy.html
非常感谢帮助。
答案 0 :(得分:0)
在PutResourcePolicyRequest中设置策略NAme和策略组。
PutResourcePolicyResult putResourcePolicy(PutResourcePolicyRequest putResourcePolicyRequest)
将putreourcepolicyrequest对象传递给putResourcePolicy并从PutResourcePolicyResult()获取响应
希望这有助于你