Skip to content

Commit

Permalink
Merge pull request #90 from dotxlem/root-service
Browse files Browse the repository at this point in the history
Flag service API as "root"
  • Loading branch information
dotxlem authored Sep 20, 2022
2 parents f637add + 3f585e9 commit 6d9a5bf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
11 changes: 8 additions & 3 deletions cli/src/providers/route53/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ impl Castable for DnsProvider {
_ => false,
},
map_to_root: d.map_to_root,
root_service: s.is_root.unwrap_or(false),
}
})
.collect_vec();
Expand Down Expand Up @@ -139,6 +140,7 @@ struct Record {
target: String,
is_apigw_target: bool,
map_to_root: bool,
root_service: bool,
}

#[derive(Serialize)]
Expand Down Expand Up @@ -172,14 +174,16 @@ data aws_route53_zone {{this.name_snaked}} {
resource aws_acm_certificate {{this.name}} {
provider = aws.{{../../project_name}}-r53
{{#unless this.map_to_root}}domain_name = "{{this.name}}.{{../../project_name}}.{{../name}}"
{{else}}domain_name = "{{this.name}}.{{../name}}"{{/unless}}
{{else}}{{#unless this.root_service}}domain_name = "{{this.name}}.{{../name}}"
{{else}}domain_name = "{{../name}}"{{/unless}}{{/unless}}
validation_method = "DNS"
}
resource aws_apigatewayv2_domain_name {{this.name}} {
provider = aws.{{../../project_name}}-r53
{{#unless this.map_to_root}}domain_name = "{{this.name}}.{{../../project_name}}.{{../name}}"
{{else}}domain_name = "{{this.name}}.{{../name}}"{{/unless}}
{{else}}{{#unless this.root_service}}domain_name = "{{this.name}}.{{../name}}"
{{else}}domain_name = "{{../name}}"{{/unless}}{{/unless}}
domain_name_configuration {
certificate_arn = aws_acm_certificate.{{this.name}}.arn
Expand Down Expand Up @@ -223,7 +227,8 @@ resource aws_route53_record {{this.name}} {
provider = aws.{{../../project_name}}-r53
zone_id = data.aws_route53_zone.{{../name_snaked}}.zone_id
{{#unless this.map_to_root}}name = "{{this.name}}.{{../../project_name}}"
{{else}}name = "{{this.name}}"{{/unless}}
{{else}}{{#unless this.root_service}}name = "{{this.name}}"
{{else}}name = "{{../name}}"{{/unless}}{{/unless}}
type = "A"
{{#unless this.is_apigw_target}}ttl = "300"
records = {{{this.target}}}
Expand Down
2 changes: 2 additions & 0 deletions cli/src/transpiler/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ impl Context {
name: service_provider.name.clone(),
options: service_provider.options.clone(),
}),
is_root: service_manifest.api.is_root,
domain_name: service_manifest.api.domain_name,
project_name: project.name.clone(),
});
Expand Down Expand Up @@ -320,6 +321,7 @@ pub struct Domain {
pub struct Service {
pub name: String,
pub provider: Rc<Provider>,
pub is_root: Option<bool>,
pub domain_name: Option<String>,
pub project_name: String,
}
Expand Down
1 change: 1 addition & 0 deletions cli/src/transpiler/toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ pub mod service {
#[derive(Serialize, Deserialize, Clone, Default)]
pub struct Api {
pub domain_name: Option<String>,
pub is_root: Option<bool>,
pub functions: Rc<Vec<Function>>,
pub authorizers: Option<Rc<Vec<HttpAuth>>>,
}
Expand Down

0 comments on commit 6d9a5bf

Please # to comment.