Skip to content

Commit

Permalink
feat: new components
Browse files Browse the repository at this point in the history
Add minimal implementations of `subscription`, `hostingplatform`
and `dnszone` components.

While commented out, there is also the start of support for dns
entry creation for the CDN component for testing of additional
resource groups on components.

Minimal support for associated resource types/services has also
been added.
  • Loading branch information
ml019 committed Sep 27, 2021
1 parent 9feb39f commit e89188a
Show file tree
Hide file tree
Showing 11 changed files with 260 additions and 2 deletions.
30 changes: 30 additions & 0 deletions aws/components/cdn/id.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,34 @@
AWS_CLOUDWATCH_SERVICE,
AWS_IDENTITY_SERVICE
]
[#--
Comment out for now to avoid errors when no locations are configured.
locations={
DEFAULT_RESOURCE_GROUP : {
"TargetComponentTypes" : [
HOSTING_PLATFORM_COMPONENT_TYPE
]
}
}
--]
/]

[#-- @addResourceGroupInformation
type=CDN_COMPONENT_TYPE
attributes=[]
provider=AWS_PROVIDER
resourceGroup=DNS_RESOURCE_GROUP
services=
[
AWS_ROUTE53_SERVICE
]
locations={
DNS_RESOURCE_GROUP : {
"TargetComponentTypes" : [
DNS_ZONE_COMPONENT_TYPE
]
}
}
/--]
40 changes: 38 additions & 2 deletions aws/components/cdn/state.ftl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[#ftl]

[#macro aws_cdn_cf_state occurrence parent={} ]
[#local core = occurrence.Core]
[#local solution = occurrence.Configuration.Solution]
[#local core = getOccurrenceCore(occurrence) ]
[#local solution = getOccurrenceSolution(occurrence) ]

[#local cfId = formatResourceId(AWS_CLOUDFRONT_DISTRIBUTION_RESOURCE_TYPE, core.Id)]
[#local cfName = core.FullName]
Expand Down Expand Up @@ -63,6 +63,42 @@
]
[/#macro]

[#macro aws_cdn_dns_cf_state occurrence parent={} ]
[#local core = getOccurrenceCore(occurrence) ]
[#local solution = getOccurrenceSolution(occurrence) ]

[#-- Assemble the required DNS entries ready for the generic AWS setup handler --]
[#local entries = {} ]

[#if isPresent(solution.Certificate) ]
[#local certificateObject = getCertificateObject(solution.Certificate) ]
[#local hostName = getHostName(certificateObject, occurrence) ]

[#-- Get alias list --]
[#list certificateObject.Domains as domain]
[#local entries +=
{
"dns" + domain?counter : {
"Id" : "dnsentry",
"Type" : "dnsentry",
"FQDN" : formatDomainName(hostName, domain.Name)
}
}
]
[/#list]
[/#if]

[#assign componentState =
{
"Resources" : entries,
"Attributes" : {},
"Roles" : {
"Inbound" : {},
"Outbound" : {}
}
}
]
[/#macro]

[#macro aws_cdnroute_cf_state occurrence parent={} ]
[#local core = occurrence.Core]
Expand Down
18 changes: 18 additions & 0 deletions aws/components/dnszone/id.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[#ftl]

[@addResourceGroupInformation
type=DNS_ZONE_COMPONENT_TYPE
attributes=[]
provider=AWS_PROVIDER
resourceGroup=DEFAULT_RESOURCE_GROUP
services=[
AWS_ROUTE53_SERVICE
]
locations={
DEFAULT_RESOURCE_GROUP : {
"TargetComponentTypes" : [
SUBSCRIPTION_COMPONENT_TYPE
]
}
}
/]
40 changes: 40 additions & 0 deletions aws/components/dnszone/state.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[#ftl]

[#macro aws_dnszone_cf_state occurrence parent={} ]
[#local core = getOccurrenceCore(occurrence) ]
[#local solution = getOccurrenceSolution(occurrence) ]
[#local locations = getOccurrenceLocations(occurrence) ]

[#-- Combine any placement attributes with explicitly provided values --]
[#local attributes =
{
"REGION" : "us-east-1"
} +
((locations[DEFAULT_RESOURCE_GROUP].Attributes)!{}) +
attributeIfContent(
"ZONE",
solution["external:ProviderId"]!""
)
]

[#assign componentState =
{
"Resources" : {
"external" : {
"Id" : formatResourceId(AWS_ROUTE53_DNS_ZONE_RESOURCE_TYPE, core.Id),
"Type" : AWS_ROUTE53_DNS_ZONE_RESOURCE_TYPE,
"Deployed" :
attributes["PROVIDER"]?has_content &&
attributes["ACCOUNT"]?has_content &&
attributes["ZONE"]?has_content
}
},
"Attributes" : attributes,
"Roles" : {
"Inbound" : {},
"Outbound" : {}
}
}
]

[/#macro]
16 changes: 16 additions & 0 deletions aws/components/hostingplatform/id.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[#ftl]

[@addResourceGroupInformation
type=HOSTING_PLATFORM_COMPONENT_TYPE
attributes=[]
provider=AWS_PROVIDER
resourceGroup=DEFAULT_RESOURCE_GROUP
services=[]
locations={
DEFAULT_RESOURCE_GROUP : {
"TargetComponentTypes" : [
SUBSCRIPTION_COMPONENT_TYPE
]
}
}
/]
36 changes: 36 additions & 0 deletions aws/components/hostingplatform/state.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[#ftl]

[#macro aws_hostingplatform_cf_state occurrence parent={} ]
[#local core = getOccurrenceCore(occurrence) ]
[#local solution = getOccurrenceSolution(occurrence) ]
[#local locations = getOccurrenceLocations(occurrence) ]

[#-- Combine any placement attributes with explicitly provided values --]
[#local attributes =
((locations[DEFAULT_RESOURCE_GROUP].Attributes)!{}) +
attributeIfContent(
"REGION",
(solution["Engine:region"].Region)!""
)
]

[#assign componentState =
{
"Resources" : {
"external" : {
"Id" : formatResourceId("external", core.Id),
"Type" : "external",
"Deployed" :
attributes["PROVIDER"]?has_content &&
attributes["ACCOUNT"]?has_content &&
attributes["REGION"]?has_content
}
},
"Attributes" : attributes,
"Roles" : {
"Inbound" : {},
"Outbound" : {}
}
}
]
[/#macro]
20 changes: 20 additions & 0 deletions aws/components/subscription/id.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[#ftl]

[@addResourceGroupInformation
type=SUBSCRIPTION_COMPONENT_TYPE
attributes=[]
provider=AWS_PROVIDER
resourceGroup=DEFAULT_RESOURCE_GROUP
services=[
AWS_ORGANIZATIONS_SERVICE
]
locations={
[#-- A link to a subscription is required if not importing the provider --]
DEFAULT_RESOURCE_GROUP : {
"Mandatory" : false,
"TargetComponentTypes" : [
SUBSCRIPTION_COMPONENT_TYPE
]
}
}
/]
42 changes: 42 additions & 0 deletions aws/components/subscription/state.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[#ftl]

[#macro aws_subscription_cf_state occurrence parent={} ]
[#local core = getOccurrenceCore(occurrence) ]
[#local solution = getOccurrenceSolution(occurrence) ]
[#local locations = getOccurrenceLocations(occurrence) ]

[#-- Combine any placement attributes with explicitly provided values --]
[#local attributes =
((locations[DEFAULT_RESOURCE_GROUP].Attributes)!{}) +
attributeIfContent(
"PROVIDER",
solution["external:Provider"]!""
) +
attributeIfContent(
"ACCOUNT",
solution["external:ProviderId"]!""
) +
attributeIfContent(
"DEPLOYMENT_FRAMEWORK",
solution["external:DeploymentFramework"]!""
)
]

[#assign componentState =
{
"Resources" : {
"external" : {
"Id" : formatResourceId(AWS_ORGANIZATIONS_ACCOUNT_RESOURCE_TYPE, core.Id),
"Type" : AWS_ORGANIZATIONS_ACCOUNT_RESOURCE_TYPE,
"Deployed" : attributes["PROVIDER"]?has_content
}
},
"Attributes" : attributes,
"Roles" : {
"Inbound" : {},
"Outbound" : {}
}
}
]

[/#macro]
10 changes: 10 additions & 0 deletions aws/services/organizations/id.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[#ftl]

[#-- Resources --]

[#assign AWS_ORGANIZATIONS_ACCOUNT_RESOURCE_TYPE = "account" ]
[@addServiceResource
provider=AWS_PROVIDER
service=AWS_ORGANIZATIONS_SERVICE
resource=AWS_ORGANIZATIONS_ACCOUNT_RESOURCE_TYPE
/]
7 changes: 7 additions & 0 deletions aws/services/route53/id.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,10 @@
service=AWS_ROUTE53_SERVICE
resource=AWS_ROUTE53_HEALTHCHECK_RESOURCE_TYPE
/]

[#assign AWS_ROUTE53_DNS_ZONE_RESOURCE_TYPE = "route53dnszone" ]
[@addServiceResource
provider=AWS_PROVIDER
service=AWS_ROUTE53_SERVICE
resource=AWS_ROUTE53_DNS_ZONE_RESOURCE_TYPE
/]
3 changes: 3 additions & 0 deletions aws/services/service.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@
[#assign AWS_NETWORK_FIREWALL_SERVICE = "networkfirewall"]
[@addService provider=AWS_PROVIDER service=AWS_NETWORK_FIREWALL_SERVICE /]

[#assign AWS_ORGANIZATIONS_SERVICE = "organizations"]
[@addService provider=AWS_PROVIDER service=AWS_ORGANIZATIONS_SERVICE /]

[#assign AWS_PINPOINT_SERVICE = "pinpoint"]
[@addService provider=AWS_PROVIDER service=AWS_PINPOINT_SERVICE /]

Expand Down

0 comments on commit e89188a

Please sign in to comment.