Commit 670b3592 authored by Cyril Plisko's avatar Cyril Plisko

Add EIP

parent c2fa0d37
Pipeline #81335571 failed with stage
in 8 minutes and 39 seconds
use cumulus::ec2::Instance;
use cumulus::ec2::{EIp, Instance};
use cumulus::Template;
fn main() {
let proxy1 = Instance::new().instance_type("t2.micro");
let proxy2 = proxy1.clone();
let eip1 = EIp::vpc();
let eip2 = EIp::vpc();
let template = Template::new()
.description("Proxy Farm")
.resource("proxy1", proxy1)
.resource("proxy1-ip", eip1)
.resource("proxy2", proxy2)
.resource("proxy2-ip", eip2)
.json_pretty();
println!("{}", template);
......
use serde::Serialize;
use crate::skip_serializing_if::SkipSerializingIf;
#[derive(Debug, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct EIp {
#[serde(skip_serializing_if = "Domain::is_default")]
domain: Domain,
#[serde(skip_serializing_if = "String::is_empty")]
instance_id: String,
#[serde(skip_serializing_if = "String::is_empty")]
public_ipv4_pool: String,
}
impl Default for EIp {
fn default() -> Self {
Self {
domain: Domain::Standard,
instance_id: String::new(),
public_ipv4_pool: String::new(),
}
}
}
impl EIp {
pub fn vpc() -> Self {
Self {
domain: Domain::Vpc,
..Self::default()
}
}
}
#[derive(Debug, PartialEq, Serialize)]
#[serde(rename_all = "lowercase")]
enum Domain {
Standard,
Vpc,
}
impl SkipSerializingIf for Domain {
fn is_default(&self) -> bool {
*self == Self::Standard
}
}
pub use blockdevice::{BlockDeviceMapping, Ebs};
pub use cpu_options::CpuOptions;
pub use credit_spec::CreditSpecification;
pub use eip::EIp;
pub use instance::Instance;
pub use instance_type::InstanceType;
......@@ -10,8 +11,6 @@ mod affinity;
mod blockdevice;
mod cpu_options;
mod credit_spec;
mod eip;
mod instance;
mod instance_type;
#[derive(Debug)]
pub struct Ec2;
use serde::Serialize;
use super::ec2::EIp;
use super::ec2::Instance;
#[derive(Debug, Serialize)]
......@@ -7,6 +8,8 @@ use super::ec2::Instance;
pub enum Resource {
#[serde(rename = "AWS::EC2::Instance")]
Instance(Instance),
#[serde(rename = "AWS::EC2::EIP")]
EIp(EIp),
}
impl Resource {
......@@ -20,3 +23,9 @@ impl From<Instance> for Resource {
Self::Instance(instance)
}
}
impl From<EIp> for Resource {
fn from(eip: EIp) -> Self {
Self::EIp(eip)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment