private IAmazonEC2 GetAwsClient(ConDepSettings settings, AwsEc2DiscoverOptionsValues awsOptions) { var creds = GetAwsCredentials(settings, awsOptions); var region = GetAwsRegion(settings, awsOptions); return(new AmazonEC2Client(creds, region)); }
private AWSCredentials GetAwsCredentials(ConDepSettings settings, AwsEc2DiscoverOptionsValues awsOptions) { if (awsOptions.Credentials != null) { return(awsOptions.Credentials); } var dynamicAwsConfig = settings.Config.OperationsConfig.Aws; if (dynamicAwsConfig != null) { string profileName = dynamicAwsConfig.Credentials.ProfileName; if (string.IsNullOrEmpty(profileName)) { if (dynamicAwsConfig.Credentials.AccessKey == null) { throw new OperationConfigException(string.Format("Configuration in environment configuration file for Credentials.AccessKey must be present for operation {0}. Optionally you can use AWS credential profile instead, but then ProfileName must be present.", GetType().Name)); } if (dynamicAwsConfig.Credentials.SecretKey == null) { throw new OperationConfigException(string.Format("Configuration in environment configuration file for Credentials.SecretKey must be present for operation {0}. Optionally you can use AWS credential profile instead, but then ProfileName must be present.", GetType().Name)); } return(new BasicAWSCredentials((string)dynamicAwsConfig.Credentials.AccessKey, (string)dynamicAwsConfig.Credentials.SecretKey)); } return(new StoredProfileAWSCredentials((string)dynamicAwsConfig.Credentials.ProfileName)); } throw new OperationConfigException(string.Format("AWS Credentials must be provided either through DSL or in configuration for operation {0}.", GetType().Name)); }
private RegionEndpoint GetAwsRegion(ConDepSettings settings, AwsEc2DiscoverOptionsValues awsOptions) { if (awsOptions.RegionEndpoint != null) { return(awsOptions.RegionEndpoint); } var dynamicAwsConfig = settings.Config.OperationsConfig.Aws; if (dynamicAwsConfig != null) { if (!string.IsNullOrWhiteSpace((string)dynamicAwsConfig.Region)) { return(RegionEndpoint.GetBySystemName((string)dynamicAwsConfig.Region)); } } throw new OperationConfigException(string.Format("AWS Region must be provided either through DSL or in configuration for operation {0}.", GetType().Name)); }
public AwsEc2DiscoverOperation(List <KeyValuePair <string, string> > tagValues, AwsEc2DiscoverOptionsValues awsOptions) { _tags = tagValues; _awsOptions = awsOptions; }