Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

One Click installer #34

Open
wants to merge 8 commits into
base: feature/cloudformation_regions
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions cloudformation/ec2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ Parameters:
Type: "String"
Default: "1"

AvailabilityZone:
Type: "String"
Description: 'is appended to region name to create az'
Default: "a"

NameTag:
Type: "String"
Default: "tine-dev"
Expand Down Expand Up @@ -259,7 +264,7 @@ Resources:
Type: "AWS::IAM::Role"
Properties:
Path: "/"
RoleName: "ssm-tine-deploy-agent-role"
RoleName: !Sub '${AgentCodeName}_ssm-tine-deploy-agent-role'
AssumeRolePolicyDocument: "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Sid\":\"\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"ec2.amazonaws.com\"},\"Action\":\"sts:AssumeRole\"}]}"
MaxSessionDuration: 3600
ManagedPolicyArns:
Expand All @@ -274,7 +279,7 @@ Resources:
Type: AWS::IAM::InstanceProfile
Properties:
Path: "/"
InstanceProfileName: "agent-instance-profile"
InstanceProfileName: !Sub "${AgentCodeName}_agent-instance-profile"
Roles:
- !Ref IAMRoleAgent

Expand All @@ -288,7 +293,7 @@ Resources:
EC2SubnetPublicA:
Type: "AWS::EC2::Subnet"
Properties:
AvailabilityZone: !Sub "${AWS::Region}a"
AvailabilityZone: !Sub "${AWS::Region}${AvailabilityZone}"
CidrBlock: "10.0.4.0/24"
VpcId:
Ref: "EC2VPC"
Expand Down Expand Up @@ -398,10 +403,17 @@ Resources:
Encrypted: true
VolumeSize: 30
VolumeType: "gp3"

AWSServiceRoleForAutoScaling:
Type: AWS::IAM::ServiceLinkedRole
Properties:
AWSServiceName: autoscaling.amazonaws.com

AutoScalingAutoScalingGroup:
Type: "AWS::AutoScaling::AutoScalingGroup"
DependsOn:
- EC2LaunchTemplate
- AWSServiceRoleForAutoScaling
Properties:
AutoScalingGroupName: "docker-agent-ami-t4g.small"
LaunchTemplate:
Expand All @@ -412,7 +424,7 @@ Resources:
DesiredCapacity: 1
Cooldown: 300
AvailabilityZones:
- !Sub "${AWS::Region}a"
- !Sub "${AWS::Region}${AvailabilityZone}"
# - "us-west-1b"
HealthCheckType: "EC2"
HealthCheckGracePeriod: 300
Expand Down
50 changes: 50 additions & 0 deletions cloudformation/genprovider/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
variable "regions" {}

# dynamic "provider" "aws" {
# for_each = local.providers
# content {
# alias = provider.value.alias
# region = provider.value.region
# }
# }

#output "debug" {
#for region in var.regions :
# value = var.regions.names

#}

locals {
region_providers = {
for region in var.regions :
replace(region, "-", "") => {
alias = replace(region, "-", "")
region = region
}
}
}

output "provider_configs" {
value = {
for alias, config in local.region_providers :
alias => "provider \"aws\" {\n alias = \"${config.alias}\"\n region = \"${config.region}\"\n}"
}
}

locals {
module_configs = {
for alias, config in local.region_providers :
alias => "module \"region_${alias}\" {\n source = \"./regional_outpost\"\n providers = { aws = aws.${alias} }\n region = \"${config.region}\"\n}"
}
}

output "module_configs" {
value = local.module_configs
}

# module "region_apsoutheast1" {
# source = "./regional_outpost"
# providers = { aws = aws.apsoutheast1 }
# region = "ap-southeast-1"
# }

Loading
Loading