每个子帐户的boto3 EC2客户端

时间:2018-08-07 13:45:23

标签: python amazon-web-services boto3

我正在尝试使用Python (:require ["d3-scale" :refer (scaleLinear)]) (let [f (-> scaleLinear (. (domain (clj->js [0 10]))) (. (range (clj->js [0 600]))))] (f 3)) Python SDK遍历子帐户,以确定VPC的使用中CIDR范围。从根帐户,我可以使用以下命令查看所有子帐户:

create procedure GetCari
    @cariid int 
as
    select 
        CariIdent, CariKod, CariNam, CariTip, CariTipEx, CariStatu 
    from 
        Cariler 
    where 
        CariIdent = @cariid

然后,我想使用EC2-> try { CrystalReportViewer cw = new CrystalReportViewer(); cw.Dock = DockStyle.Fill; panel1.Controls.Add(cw); ReportDocument cryRpt = new ReportDocument(); TableLogOnInfos crtableLogoninfos = new TableLogOnInfos(); TableLogOnInfo crtableLogoninfo = new TableLogOnInfo(); ConnectionInfo crConnectionInfo = new ConnectionInfo(); Tables CrTables; ParameterField paramField = new ParameterField(); ParameterFields paramFields = new ParameterFields(); ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue(); paramField.Name = "@cariid"; paramDiscreteValue.Value = 1; paramField.CurrentValues.Add(paramDiscreteValue); paramFields.Add(paramField); cw.ParameterFieldInfo = paramFields; string path = @"C:\..\Reports\Report2.rpt"; cryRpt.Load(path); ParameterFieldDefinitions crParameterFieldDefinitions; ParameterFieldDefinition crParameterFieldDefinition; ParameterValues crParameterValues = new ParameterValues(); ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue(); crParameterDiscreteValue.Value = Convert.ToInt32(1); crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields; crParameterFieldDefinition = crParameterFieldDefinitions["@cariid"]; crParameterValues = crParameterFieldDefinition.CurrentValues; crParameterValues.Clear(); crParameterValues.Add(crParameterDiscreteValue); crParameterFieldDefinition.ApplyCurrentValues(crParameterValues); crConnectionInfo.ServerName = "server"; crConnectionInfo.DatabaseName = "db"; crConnectionInfo.UserID = "sa"; crConnectionInfo.Password = "1234"; CrTables = cryRpt.Database.Tables; foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables) { crtableLogoninfo = CrTable.LogOnInfo; crtableLogoninfo.ConnectionInfo = crConnectionInfo; CrTable.ApplyLogOnInfo(crtableLogoninfo); } cryRpt.SetParameterValue("@cariid", 1); cryRpt.VerifyDatabase(); cryRpt.Refresh(); cw.ReportSource = cryRpt; cw.Refresh(); } catch (Exception ex) { MessageBox.Show(ex.Message); } 来识别使用中的CIDR范围。有人可以给我一些有关连接这两部分的建议吗?

1 个答案:

答案 0 :(得分:1)

您的代码需要在每个子帐户中承担角色。然后,这将提供临时凭证,可用于在子帐户中进行API调用。

来自Accessing and Administering the Member Accounts in Your Organization - AWS Organizations

  

当您在组织中创建帐户时,AWS Organizations会自动为该帐户创建一个root用户和一个IAM角色。 ...如果您在组织中创建帐户,则可以使用通过这种方式创建的所有新帐户中存在的预配置角色访问该帐户。

     

...

     

当您使用AWS Organizations控制台创建成员帐户时,AWS Organizations会在该帐户中自动创建一个 IAM角色。此角色在成员帐户中具有完全管理权限。该角色还配置为授予对组织主帐户的访问权限