如何在我的.net源代码中对我的accesskey和秘密访问密钥进行硬编码?

时间:2016-02-04 21:11:18

标签: c# .net aws-sdk

var ec2Client = new AmazonEC2Client();
string amiID = "ami;
string keyPairName = "aaaa";

// List<string> groups = new List<string>() ;
var launchRequest = new RunInstancesRequest()
{
    ImageId = amiID,
    InstanceType = "tttt",
    MinCount = 1,
    MaxCount = 1,
    KeyName = kkkk,
    SubnetId = "bbbb",
};

如何对访问密钥和密钥访问密钥进行硬编码?

1 个答案:

答案 0 :(得分:0)

var awsCreds = new BasicAWSCredentials("ACCESS_KEY", "SECRET_KEY");
var ec2Config = new AmazonEC2Config() {
    // add configurations here, 
    // such as ServiceURL and RegionEndpoint
}
var ec2Client = new AmazonEC2Client(awsCreds, ec2Config);

了解详情:

无论如何,不​​建议使用硬编码访问密钥和密钥。请务必谨慎,尤其是当您要将代码共享到公共存储库时。