-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add sub domain and cert to org formation (#786)
Signed-off-by: hxtree <[email protected]>
- Loading branch information
Showing
7 changed files
with
184 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
OrganizationUpdate: | ||
Type: update-organization | ||
Template: ./organization.yml | ||
|
||
SubDomains: | ||
Type: update-stacks | ||
Template: ./templates/subdomains.yml | ||
StackName: SubDomains | ||
Parameters: | ||
rootHostedZoneName: nekosgate.com | ||
MaxConcurrentStacks: 10 | ||
FailedStackTolerance: 10 | ||
|
||
WildCardCerts: | ||
Type: update-stacks | ||
Template: ./templates/wildcard-certs.yml | ||
StackName: WildCardCerts | ||
Parameters: | ||
rootHostedZoneName: nekosgate.com | ||
resourcePrefix: orgformation | ||
MaxConcurrentStacks: 10 | ||
FailedStackTolerance: 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,11 @@ AWSTemplateFormatVersion: '2010-09-09-OC' | |
Description: default template generated for organization with master account 124653296725 | ||
|
||
Organization: | ||
ManagementAccount: | ||
|
||
MasterAccount: | ||
Type: OC::ORG::MasterAccount | ||
Properties: | ||
AccountName: Matt Heroux | ||
AccountName: root | ||
AccountId: '124653296725' | ||
RootEmail: [email protected] | ||
|
||
|
@@ -17,21 +18,25 @@ Organization: | |
- !Ref DenyChangeOfOrgRoleSCP | ||
- !Ref RestrictUnusedRegionsSCP | ||
|
||
SandboxAccount: | ||
ToolsAccount: | ||
Type: OC::ORG::Account | ||
Properties: | ||
AccountName: tools | ||
AccountId: '760440398296' | ||
RootEmail: matthew.heroux+1@gmail.com | ||
RootEmail: matthew.heroux+tools@gmail.com | ||
Alias: tools-1 | ||
Tags: | ||
subdomain: tools | ||
|
||
SandboxAccount: | ||
Type: OC::ORG::Account | ||
Properties: | ||
AccountName: Sandbox | ||
AccountName: sandbox | ||
AccountId: '298217020330' | ||
RootEmail: [email protected] | ||
Alias: dev-1 | ||
RootEmail: [email protected] | ||
# Alias: sandbox-1 | ||
Tags: | ||
subdomain: sandbox | ||
|
||
RestrictUnusedRegionsSCP: | ||
Type: OC::ORG::ServiceControlPolicy | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#!/bin/bash | ||
|
||
org-formation update organization.yml --profile=Administrator | ||
org-formation perform-tasks organization-tasks.yml --profile=Administrator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
AWSTemplateFormatVersion: '2010-09-09-OC' | ||
|
||
# Include file that contains Organization Section. | ||
# The Organization Section describes Accounts, Organizational Units, etc. | ||
Organization: !Include ../organization.yml | ||
|
||
# Any Binding that does not explicitly specify a region will default to this. | ||
# Value can be either string or list | ||
DefaultOrganizationBindingRegion: us-east-2 | ||
|
||
Parameters: | ||
resourcePrefix: | ||
Type: String | ||
Default: my | ||
|
||
rootHostedZoneName: | ||
Type: String | ||
|
||
# Section contains a named set of Bindings. | ||
# Bindings determine what resources are deployed where | ||
# These bindings can be !Ref'd from the Resources in the resource section | ||
OrganizationBindings: | ||
|
||
# binding for HostedZone, HostedZoneIdParam, HostedZoneNameParam | ||
HostedZoneBinding: | ||
AccountsWithTag: subdomain | ||
|
||
# binding for RootHostedZone, ParentNsRecord | ||
RootHostedZoneBinding: | ||
IncludeMasterAccount: true | ||
|
||
Resources: | ||
|
||
#=========================================# | ||
# Zone | ||
#=========================================# | ||
|
||
HostedZone: | ||
Type: AWS::Route53::HostedZone | ||
OrganizationBinding: !Ref HostedZoneBinding | ||
Properties: | ||
HostedZoneConfig: | ||
Comment: Domain Hosted Zone | ||
Name: !Sub '${AWSAccount.Tags.subdomain}.${rootHostedZoneName}.' | ||
|
||
HostedZoneIdParam: | ||
Type: AWS::SSM::Parameter | ||
OrganizationBinding: !Ref HostedZoneBinding | ||
Properties: | ||
Name: !Sub '${resourcePrefix}-domains-hosted-zone-id' | ||
Type: String | ||
Value: !GetAtt AWSAccount.Resources.HostedZone | ||
|
||
HostedZoneNameParam: | ||
Type: AWS::SSM::Parameter | ||
OrganizationBinding: !Ref HostedZoneBinding | ||
Properties: | ||
Name: !Sub '${resourcePrefix}-domains-hosted-zone-name' | ||
Type: String | ||
Value: !Sub '${AWSAccount.Tags.subdomain}.${rootHostedZoneName}.' | ||
|
||
#=========================================# | ||
# Parent Record | ||
#=========================================# | ||
|
||
RootHostedZone: | ||
Type: AWS::Route53::HostedZone | ||
OrganizationBinding: !Ref RootHostedZoneBinding | ||
Properties: | ||
HostedZoneConfig: | ||
Comment: Root domain | ||
Name: !Ref rootHostedZoneName | ||
|
||
# be aware that changing the logicalName for a AWS::Route53::RecordSet resource | ||
# might result in an error. workaround is to remove the resource and then add it. | ||
ParentNsRecord: | ||
DependsOn: RootHostedZone | ||
Type: AWS::Route53::RecordSet | ||
OrganizationBinding: !Ref RootHostedZoneBinding | ||
ForeachAccount: !Ref HostedZoneBinding | ||
Properties: | ||
Type: NS | ||
HostedZoneName: !Sub '${rootHostedZoneName}.' | ||
Name: !Sub '${CurrentAccount.Tags.subdomain}.${rootHostedZoneName}.' | ||
TTL: 86400 | ||
ResourceRecords: !GetAtt CurrentAccount.Resources.HostedZone.NameServers |
42 changes: 42 additions & 0 deletions
42
platform/aws-org-formation/bin/templates/wildcard-certs.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
AWSTemplateFormatVersion: '2010-09-09-OC' | ||
|
||
Organization: !Include ../organization.yml | ||
|
||
OrganizationBindings: | ||
|
||
CertificateBinding: | ||
Region: | ||
- us-east-2 | ||
AccountsWithTag: subdomain | ||
|
||
Parameters: | ||
|
||
resourcePrefix: | ||
Type: String | ||
|
||
rootHostedZoneName: | ||
Type: String | ||
|
||
Resources: | ||
|
||
LocalCert1: | ||
Type: AWS::CertificateManager::Certificate | ||
OrganizationBinding: !Ref CertificateBinding | ||
Properties: | ||
DomainName: !Sub '*.${AWSAccount.Tags.subdomain}.${rootHostedZoneName}' | ||
SubjectAlternativeNames: | ||
- !Sub '${AWSAccount.Tags.subdomain}.${rootHostedZoneName}' | ||
ValidationMethod: DNS | ||
DomainValidationOptions: | ||
- DomainName: !Sub '${AWSAccount.Tags.subdomain}.${rootHostedZoneName}' | ||
ValidationDomain: !Ref rootHostedZoneName | ||
- DomainName: !Sub '*.${AWSAccount.Tags.subdomain}.${rootHostedZoneName}' | ||
ValidationDomain: !Ref rootHostedZoneName | ||
|
||
LocalCert1ArnParam: | ||
Type: AWS::SSM::Parameter | ||
OrganizationBinding: !Ref CertificateBinding | ||
Properties: | ||
Name: !Sub '${resourcePrefix}-certs-wildcard-cert1-arn' | ||
Type: String | ||
Value: !Ref LocalCert1 |