Skip to content

Commit

Permalink
add security_group for AWSProvisioner
Browse files Browse the repository at this point in the history
  • Loading branch information
lleyton committed Dec 17, 2023
1 parent 724d2f7 commit 267ac0c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/cloud/aws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ pub struct AWSProvisioner {
pub region: String,
/// Reference to a secret containing the AWS access key ID and secret access key, under the access_key_id and secret_access_key keys
pub auth: String,
/// Security group name to use for the exit node, uses the default security group if not specified
pub security_group: Option<String>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
Expand Down Expand Up @@ -126,16 +128,20 @@ impl Provisioner for AWSProvisioner {
.tags(Tag::builder().key("Name").value(name.clone()).build())
.build();

let instance_response = ec2_client
let mut instance_builder = ec2_client
.run_instances()
.tag_specifications(tag_specification)
.image_id(ami)
.instance_type("t2.micro".into())
.min_count(1)
.max_count(1)
.user_data(&user_data)
.send()
.await?;
.user_data(&user_data);

if let Some(security_group) = &self.security_group {
instance_builder = instance_builder.security_group_ids(security_group);
}

let instance_response = instance_builder.send().await?;

let instance = instance_response
.instances
Expand Down

0 comments on commit 267ac0c

Please sign in to comment.