Ejemplo n.º 1
0
//Button 4 - CloudBerry
        private void button4_Click(object sender, EventArgs e)
        {
            var oldpolicy = "";

            txtOutput.Text += "Editing CB Role Policy" + "\r\n";

            var client = new AmazonIdentityManagementServiceClient();

            var getcurrentrequest = new GetRolePolicyRequest
            {
                PolicyName = "CloudBerryMBSPolicy",
                RoleName   = "CloudBerryMBSRole-6bba62a8-a0da-497c-b296-2fe588c64db4"
            };

            try
            {
                var getPolicyResponse = client.GetRolePolicy(getcurrentrequest);
                oldpolicy = System.Net.WebUtility.UrlDecode(getPolicyResponse.PolicyDocument);
            }
            catch (NoSuchEntityException)
            {
                txtOutput.Text += "Policy does not exist." + "\r\n";
            }
            var newpolicy = oldpolicy.Remove(oldpolicy.Length - 3, 3);

            newpolicy += ",{\"Effect\": \"Allow\",  \"Action\": \"s3:*\", \"Resource\": [  \"arn:aws:s3:::" + txtID.Text + "\"], \"Condition\": {} }, {\"Effect\": \"Allow\",  \"Action\": \"s3:*\", \"Resource\": [  \"arn:aws:s3:::" + txtID.Text + "/*\"], \"Condition\": {} }  ] }";


            var putrolepolicyrequest = new PutRolePolicyRequest
            {
                RoleName       = "CloudBerryMBSRole-6bba62a8-a0da-497c-b296-2fe588c64db4",
                PolicyName     = "CloudBerryMBSPolicy",
                PolicyDocument = newpolicy
            };

            try
            {
                var putPolicyResponse = client.PutRolePolicy(putrolepolicyrequest);
                txtOutput.Text += "CloudBerry Role Policy Update - Success \r\n";
            }
            catch (NoSuchEntityException)
            {
                txtOutput.Text += "Policy does not exist." + "\r\n";
            }
        }
 public Task <GetRolePolicyResponse> GetRolePolicyAsync(GetRolePolicyRequest request, CancellationToken cancellationToken = new CancellationToken())
 {
     throw new System.NotImplementedException();
 }
Ejemplo n.º 3
0
 public Task <GetRolePolicyResponse> GetPolicyAsync(GetRolePolicyRequest getRolePolicyRequest)
 {
     return(Task.FromResult(GetPolicyAsyncResponse()));
 }
 public Task <GetRolePolicyResponse> GetPolicyAsync(GetRolePolicyRequest getRolePolicyRequest)
 {
     return(_client.GetRolePolicyAsync(getRolePolicyRequest));
 }