Skip to content
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
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# cloudformation files

here are files from terraform in clouformation, needs to be cleaned up.

Idea:
results of cloudformation created from terraformed results.
use terraform to deploy
capture as cloudformation
parameterize
create one click deploy of cloudformation.

# one click installer plan

Using cloudformation
Expand Down
30 changes: 30 additions & 0 deletions accounts/np-introspector/constants.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

variable "lock_resource" {
type = string
default = "terraform/state/lock"
}

variable "partition" {
type = string
default = "aws"
}

variable "logs_resource" {
type = string
default = "aws_logs"
}

variable "permissions_check" {
type = string
default = "config-permissions-check"
}

variable "delivery_service" {
type = string
default = "delivery.logs.amazonaws.com"
}

variable "logging_service" {
type = string
default = "logging.s3.amazonaws.com"
}
67 changes: 67 additions & 0 deletions accounts/np-introspector/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
provider "aws" {
region = "ap-south-1"
profile = "np-introspector"
}

locals { ami_name = "ubuntu-minimal/images/hvm-ssd-gp3/ubuntu-noble-24.04-amd64-minimal-*" }

data "aws_ami" "ami" { # slow
most_recent = true
name_regex = "^${local.ami_name}"
}


locals {
# hard coded to save time , fixme use a caching system
# ami_id = "ami-0325b9a2dfb474b2d" for ami_name = "ubuntu-minimal/images/hvm-ssd-gp3/ubuntu-noble-24.04-amd64-minimal-*" }
# ami_id = "ami-0e44962f5c9a2baab"
ami_id = data.aws_ami.ami.id
}

module "ssm_observer" {
source = "../../modules/aws/ssm/observability"
ami_id = local.ami_id
}

module "ssm_setup" {
source = "../../modules/aws/ssm/setup"
bucket_name = "${var.codename}-session-logs"
access_log_bucket_name = "${var.codename}-session-access-logs"
project = "${var.codename}"
}


# now after we create the above resources, we can do the following,
# FIXME need to add dependencies
module "eliza_server" {
depends_on = [
# module.ssm_setup.
#│ arn:aws:ssm:ap-south-2:084375543224:parameter/cloudwatch-agent/config/details
module.ssm_observer #.aws_ssm_parameter.cw_agent_config,
# module.ssm_observer.aws_ssm_parameter.cw_agent_config_details
]
#count = 0
#aws_account_id = var.account
aws_account_id =var.aws_account_id
region = var.aws_region
source = "../../environments/eliza-agent-api"
domain = var.dns_name
key_name = "mdupont-deployer-key"
branch = "feature/arm64_fastembed"
project = var.codename
instance_types = ["t4g.small"] # not big enough for building

repo = "https://github.com/meta-introspector/cloud-deployment-eliza/"
aws_availability_zones =[
"${var.aws_region}a",
"${var.aws_region}b",
"${var.aws_region}c" # FIXME
]

# FIXME not used right now
spot_max_price= 0.01
ami_id = local.ami_id #
name = "${var.codename}"
tags = { project = "${var.codename}" }
}

37 changes: 37 additions & 0 deletions accounts/np-introspector/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
variable "dns_name" {
type = string
default = "np.introspector.meme"
}

variable "codename" {
type = string
default = "hanuman"
}

variable "project_name" {
type = string
default = "np-introspector"
}

variable "profile" {
type = string
default = "np-introspector"
}

variable "aws_region" {
type = string
default = "ap-south-2"
}

variable "aws_account_id" {
type = string
default = "084375543224"
}

variable "iam_user" {
type = string
default = "np_introspector"
}



48 changes: 48 additions & 0 deletions cloudformation/asg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
AutoScalingScalingPolicy:
Type: "AWS::AutoScaling::ScalingPolicy"
Properties:
AutoScalingGroupName: !Sub "docker-agent-ami-t4g.small-20${SSMParameter.Value}0127184935601900000001"
PolicyType: "TargetTrackingScaling"
EstimatedInstanceWarmup: 1200
TargetTrackingConfiguration:
PredefinedMetricSpecification:
PredefinedMetricType: "ASGAverageCPUUtilization"
TargetValue: 50
DisableScaleIn: false

AutoScalingScalingPolicy2:
Type: "AWS::AutoScaling::ScalingPolicy"
Properties:
AutoScalingGroupName: !Sub "docker-agent-ami-t4g.small-20${SSMParameter.Value}0127184935601900000001"
PolicyType: "StepScaling"
AdjustmentType: "ExactCapacity"
StepAdjustments:
-
MetricIntervalLowerBound: 0
MetricIntervalUpperBound: 10
ScalingAdjustment: 1
-
MetricIntervalLowerBound: 10
ScalingAdjustment: 2
MetricAggregationType: "Average"
EstimatedInstanceWarmup: 120

AutoScalingScalingPolicy3:
Type: "AWS::AutoScaling::ScalingPolicy"
Properties:
AutoScalingGroupName: !Sub "docker-agent-ami-t4g.small-20${SSMParameter.Value}0127184935601900000001"
PolicyType: "PredictiveScaling"
PredictiveScalingConfiguration:
MetricSpecifications:
-
TargetValue: 32
PredefinedScalingMetricSpecification:
PredefinedMetricType: "ASGAverageCPUUtilization"
ResourceLabel: !Sub "${CURReportDefinition}Label"
PredefinedLoadMetricSpecification:
PredefinedMetricType: "ASGTotalCPUUtilization"
ResourceLabel: !Sub "${CURReportDefinition}Label"
Mode: "ForecastAndScale"
SchedulingBufferTime: 10
MaxCapacityBreachBehavior: "IncreaseMaxCapacity"
MaxCapacityBuffer: 10
44 changes: 44 additions & 0 deletions cloudformation/cdk.cf
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
IAMRole00cdkhnb659fdsimagepublishingrole767503528736useast100kkdnQ:
UpdateReplacePolicy: "Retain"
Type: "AWS::IAM::Role"
DeletionPolicy: "Retain"
Properties:
Path: "/"
MaxSessionDuration: 3600
RoleName: "cdk-hnb659fds-image-publishing-role-767503528736-us-east-1"
Description: ""
Policies:
- PolicyDocument:
Version: "2012-10-17"
Statement:
- Resource: "arn:aws:ecr:us-east-1:767503528736:repository/cdk-hnb659fds-container-assets-767503528736-us-east-1"
Action:
- "ecr:PutImage"
- "ecr:InitiateLayerUpload"
- "ecr:UploadLayerPart"
- "ecr:CompleteLayerUpload"
- "ecr:BatchCheckLayerAvailability"
- "ecr:DescribeRepositories"
- "ecr:DescribeImages"
- "ecr:BatchGetImage"
- "ecr:GetDownloadUrlForLayer"
Effect: "Allow"
- Resource: "*"
Action:
- "ecr:GetAuthorizationToken"
Effect: "Allow"
PolicyName: "cdk-hnb659fds-image-publishing-role-default-policy-767503528736-us-east-1"
AssumeRolePolicyDocument:
Version: "2008-10-17"
Statement:
- Action: "sts:TagSession"
Effect: "Allow"
Principal:
AWS: "arn:aws:iam::767503528736:root"
- Action: "sts:AssumeRole"
Effect: "Allow"
Principal:
AWS: "arn:aws:iam::767503528736:root"
Tags:
- Value: "image-publishing"
Key: "aws-cdk:bootstrap-role"
44 changes: 44 additions & 0 deletions cloudformation/cdl.cf
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
IAMRole00cdkhnb659fdsimagepublishingrole767503528736useast100kkdnQ:
UpdateReplacePolicy: "Retain"
Type: "AWS::IAM::Role"
DeletionPolicy: "Retain"
Properties:
Path: "/"
MaxSessionDuration: 3600
RoleName: "cdk-hnb659fds-image-publishing-role-767503528736-us-east-1"
Description: ""
Policies:
- PolicyDocument:
Version: "2012-10-17"
Statement:
- Resource: "arn:aws:ecr:us-east-1:767503528736:repository/cdk-hnb659fds-container-assets-767503528736-us-east-1"
Action:
- "ecr:PutImage"
- "ecr:InitiateLayerUpload"
- "ecr:UploadLayerPart"
- "ecr:CompleteLayerUpload"
- "ecr:BatchCheckLayerAvailability"
- "ecr:DescribeRepositories"
- "ecr:DescribeImages"
- "ecr:BatchGetImage"
- "ecr:GetDownloadUrlForLayer"
Effect: "Allow"
- Resource: "*"
Action:
- "ecr:GetAuthorizationToken"
Effect: "Allow"
PolicyName: "cdk-hnb659fds-image-publishing-role-default-policy-767503528736-us-east-1"
AssumeRolePolicyDocument:
Version: "2008-10-17"
Statement:
- Action: "sts:TagSession"
Effect: "Allow"
Principal:
AWS: "arn:aws:iam::767503528736:root"
- Action: "sts:AssumeRole"
Effect: "Allow"
Principal:
AWS: "arn:aws:iam::767503528736:root"
Tags:
- Value: "image-publishing"
Key: "aws-cdk:bootstrap-role"
Loading
Loading