From f08b19e0ec5e712925249ec30d8d5b0da9fc8ba9 Mon Sep 17 00:00:00 2001 From: nikita-skobov Date: Sun, 25 Jun 2023 13:35:28 -0600 Subject: [PATCH] adds hosted docs site --- hosted/README.md | 3 ++ hosted/hiracliwebsite/.gitignore | 1 + hosted/hiracliwebsite/Cargo.toml | 17 +++++++++++ hosted/hiracliwebsite/src/lib.rs | 50 ++++++++++++++++++++++++++++++++ 4 files changed, 71 insertions(+) create mode 100644 hosted/README.md create mode 100644 hosted/hiracliwebsite/.gitignore create mode 100644 hosted/hiracliwebsite/Cargo.toml create mode 100644 hosted/hiracliwebsite/src/lib.rs diff --git a/hosted/README.md b/hosted/README.md new file mode 100644 index 0000000..297fe66 --- /dev/null +++ b/hosted/README.md @@ -0,0 +1,3 @@ +# Hosted directory + +This directory is where I keep all hira code related to deploying infrastructure. For example, the hira public documentation site is defined here. diff --git a/hosted/hiracliwebsite/.gitignore b/hosted/hiracliwebsite/.gitignore new file mode 100644 index 0000000..aaa56ec --- /dev/null +++ b/hosted/hiracliwebsite/.gitignore @@ -0,0 +1 @@ +hira \ No newline at end of file diff --git a/hosted/hiracliwebsite/Cargo.toml b/hosted/hiracliwebsite/Cargo.toml new file mode 100644 index 0000000..7b20dfd --- /dev/null +++ b/hosted/hiracliwebsite/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "hiracliwebsite" +version = "0.1.0" +edition = "2021" + + +[dependencies] +hira = { path = "../../hira" } +dotenv_reader = { path = "../../level2/dotenv_reader" } +aws_cfn_stack = { path = "../../level2/aws_cfn_stack" } +aws_s3 = { path = "../../level2/aws_s3" } +aws_cloudfront_distribution = { path = "../../level2/aws_cloudfront_distribution" } +# third party dependencies can be added via extern crate: +#iam = { git = "https://github.com/nikita-skobov/aws_cfn_type_gen", rev = "66daeace6fbf11761026201728131bd9c668210b" } +#cloud_front = { git = "https://github.com/nikita-skobov/aws_cfn_type_gen", rev = "66daeace6fbf11761026201728131bd9c668210b" } +cfn_resources = { git = "https://github.com/nikita-skobov/aws_cfn_type_gen", rev = "66daeace6fbf11761026201728131bd9c668210b" } +tokio = { version = "*", features = ["full"]} diff --git a/hosted/hiracliwebsite/src/lib.rs b/hosted/hiracliwebsite/src/lib.rs new file mode 100644 index 0000000..9025786 --- /dev/null +++ b/hosted/hiracliwebsite/src/lib.rs @@ -0,0 +1,50 @@ +use hira::hira; +use aws_s3::aws_s3; +use dotenv_reader::dotenv_reader; +use ::aws_cloudfront_distribution::s3_website_distribution::s3_website_distribution; + +#[hira] +pub mod myvars { + use super::dotenv_reader; + + pub mod outputs { + pub const ACM_ARN: &str = "this will be replaced by the value in the .env file. If not found, this string will be used as the default"; + pub const MY_DOMAIN: &str = "hiracli.com"; + } + + pub fn config(inp: &mut dotenv_reader::Input) { + inp.dotenv_path = ".env".to_string(); + } +} + +#[hira] +pub mod hiradocs_bucket { + use super::aws_s3; + pub mod outputs { + pub use super::aws_s3::outputs::*; + } + pub fn config(inp: &mut aws_s3::Input) { + inp.is_website = true; + } +} + +#[hira] +pub mod websitedistr { + use super::myvars::outputs::{ACM_ARN, MY_DOMAIN}; + use super::hiradocs_bucket::outputs::LOGICAL_BUCKET_NAME; + use super::s3_website_distribution; + use self::s3_website_distribution::CustomDomainSettings; + + pub fn config(distrinput: &mut s3_website_distribution::Input) { + distrinput.logical_bucket_website_url = LOGICAL_BUCKET_NAME.to_string(); + distrinput.custom_domain_settings = Some( + CustomDomainSettings { + acm_arn: ACM_ARN.to_string(), + domain_name: MY_DOMAIN.to_string(), + subdomain: Some("docs".to_string()), + enable_route_53: false, + ..Default::default() + } + ); + } +}