[英]AWS Elasticsearch Service - Manual Snapshot to S3
我嘗試創建我的“Amazon Elasticsearch Service”的手動快照我找到了這個文檔,但是我在最后一步“注冊快照存儲庫”中遇到了問題。 我搜索了 .net 的解決方案,但此示例是一個 python 腳本,我找不到 .net 的解決方案
是否有可用於簽署 c# 請求的解決方案?
phyton 腳本來簽署請求
from boto.connection import AWSAuthConnection
class ESConnection(AWSAuthConnection):
def __init__(self, region, **kwargs):
super(ESConnection, self).__init__(**kwargs)
self._set_auth_region_name(region)
self._set_auth_service_name("es")
def _required_auth_capability(self):
return ['hmac-v4']
if __name__ == "__main__":
client = ESConnection(
region='eu-west-1',
host='search-domain.eu-west-1.es.amazonaws.com',
profile_name='ifOtherThanDefault',
is_secure=False)
print 'Registering Snapshot Repository'
resp = client.make_request(method='PUT',
path='/_snapshot/es-index-backups',
data='{"type": "s3","settings": { "bucket": "my-es-snapshot-repo","region": "eu-west-1","role_arn": "arn:aws:iam::123456789012:role/es-snapshots-role"}}')
body = resp.read()
print body
C#解決方案
var createRoleJson = @"{
""Version"": ""2012-10-17"",
""Statement"": [
{
""Sid"": """",
""Effect"": ""Allow"",
""Principal"": {
""Service"": ""es.amazonaws.com""
},
""Action"": ""sts:AssumeRole""
}
]
}
";
var createPolicyJson = @"{
""Version"":""2012-10-17"",
""Statement"":[
{
""Action"":[
""s3:ListBucket""
],
""Effect"":""Allow"",
""Resource"":[
""arn:aws:s3:::my-es-snapshot-repo""
]
},
{
""Action"":[
""s3:GetObject"",
""s3:PutObject"",
""s3:DeleteObject"",
""iam:PassRole""
],
""Effect"":""Allow"",
""Resource"":[
""arn:aws:s3:::my-es-snapshot-repo/*""
]
}
]
}";
亞馬遜請求 (AWSSDK.IdentityManagement)
//Change the bucket to the correct bucket
var s3BucketName = "test.elasticsearch";
createPolicyJson = createPolicyJson.Replace("my-es-snapshot-repo", s3BucketName);
var awsCredentials = new BasicAWSCredentials("accessKey", "secretKey");
var client = new AmazonIdentityManagementServiceClient(awsCredentials, Amazon.RegionEndpoint.EUCentral1);
var createRoleRequest = new CreateRoleRequest
{
RoleName = "ElasticsearchSnapshotsRole",
AssumeRolePolicyDocument = createRoleJson
};
var createPolicyRequest = new CreatePolicyRequest
{
PolicyName = "ElasticsearchSnapshotAccess",
PolicyDocument = createPolicyJson
};
var responseCreateRole = client.CreateRole(createRoleRequest);
var responseCreatePolicy = client.CreatePolicy(createPolicyRequest);
var responseAttachRolePolicy = client.AttachRolePolicy(new AttachRolePolicyRequest { PolicyArn = responseCreatePolicy.Policy.Arn, RoleName = responseCreateRole.Role.RoleName });
您可以在此處找到有關創建簽名 HTTP 請求的參考代碼: https : //docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/CreateSignatureInCSharp.html
有關 AWS elasticsearch 手動快照過程的完整詳細信息,請訪問: https : //docs.aws.amazon.com/elasticsearch-service/latest/developerguide/es-managedomains-snapshots.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.