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",
};
如何对访问密钥和密钥访问密钥进行硬编码?
答案 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);
了解详情:
无论如何,不建议使用硬编码访问密钥和密钥。请务必谨慎,尤其是当您要将代码共享到公共存储库时。