407 lines
17 KiB
Go
407 lines
17 KiB
Go
package main
|
|
|
|
const DeploymentNameSuffix = "navi-service"
|
|
const DefaultInfraVertical = "lending"
|
|
const DefaultOwner = "lending"
|
|
|
|
type Deployment struct {
|
|
Namespace string `json:"namespace"`
|
|
Cluster string `json:"cluster"`
|
|
}
|
|
|
|
type Actions struct {
|
|
Plan bool `default:"false"`
|
|
Destroy bool `default:"false"`
|
|
TemplateOnly bool `default:"false"`
|
|
Apply bool `default:"false"`
|
|
RunAdditionalScripts bool `default:"true"`
|
|
}
|
|
|
|
type Flink struct {
|
|
Namespace string `json:"namespace"`
|
|
}
|
|
|
|
type Manifest struct {
|
|
Environment string `json:"environment"`
|
|
Cluster string `json:"cluster"`
|
|
Metadata *Metadata `json:"metadata" valid:"required"`
|
|
ExtraResources *ExtraResources `json:"extraResources" valid:"required"`
|
|
Team *Team `json:"team"`
|
|
Deployment *Deployment `json:"deployment"`
|
|
Flink *Flink `json:"flink"`
|
|
Name string `json:"name"`
|
|
NameSuffix string
|
|
StateStoreBackend *StateStoreBackend
|
|
InfraVertical string `json:"infraVertical"`
|
|
Actions *Actions
|
|
}
|
|
|
|
type Metadata struct {
|
|
Repo string `json:"repo,omitempty"`
|
|
Language string `json:"language,omitempty"`
|
|
DataSensitivity string `json:"dataSensitivity,omitempty"`
|
|
LogCriticality string `json:"logCriticality,omitempty"`
|
|
DisasterRecovery string `json:"disasterRecovery,omitempty"`
|
|
Product string `json:"product,omitempty"`
|
|
}
|
|
|
|
type ExtraResources struct {
|
|
//TODO: Remove environment from ExtraResources once all apps have migrated to new schema
|
|
Environment string `json:"environment"`
|
|
Workspace string `json:"workspace"`
|
|
Database *Database `json:"database" module:"rds,auroradb" moduleDir:"rds-tf,aurora-db-tf"`
|
|
// TBD: remove undersocre from json key. to keep naming conventions same across board
|
|
ServiceRole *ServiceRole `json:"aws_access" module:"roles" moduleDir:"aws-roles-tf"`
|
|
S3Buckets []S3Bucket `json:"s3_buckets" module:"s3_buckets" moduleDir:"aws-s3-bucket-tf"`
|
|
ElasticCache *ElasticCache `json:"elasticCache" module:"elasticCache" moduleDir:"elastic-cache-tf"`
|
|
DocDb *DocDb `json:"docdb" module:"docdb" moduleDir:"document-db-tf"`
|
|
Dynamodb *Dynamodb `json:"dynamodb" module:"dynamodb" moduleDir:"dynamo-db-tf"`
|
|
GlobalTags *GlobalTags
|
|
}
|
|
|
|
type GlobalTags struct {
|
|
Environment string
|
|
}
|
|
|
|
type Dynamodb struct {
|
|
Tables []DynamodbTables `json:"tables"`
|
|
}
|
|
|
|
type DynamodbTables struct {
|
|
TableName string `json:"tableName"`
|
|
ReadMinCapacity int `json:"minReadCapacity"`
|
|
WriteMinCapacity int `json:"minWriteCapacity"`
|
|
ReadTargetValue int `json:"readTargetValue"`
|
|
WriteTargetValue int `json:"writeTargetValue"`
|
|
ReadMaxCapacity int `json:"maxReadCapacity"`
|
|
WriteMaxCapacity int `json:"maxWriteCapacity"`
|
|
BillingMode string `json:"billingMode"`
|
|
HashKey string `json:"hashKey"`
|
|
RangeKey string `json:"rangeKey"`
|
|
Lsi []DynamodbLsi `json:"lsi"`
|
|
Gsi []DynamodbGsi `json:"gsi"`
|
|
Attributes []struct {
|
|
Name string `json:"name"`
|
|
Type string `json:"value"`
|
|
} `json:"attributes"`
|
|
Ttl struct {
|
|
AttributeName string `json:"attribute_name"`
|
|
Enabled bool `json:"enabled"`
|
|
} `json:"ttl"`
|
|
DynamodbAlertThresholds *DynamodbAlertThresholds `json:"dynamoDbAlertDurations"`
|
|
DynamodbAlertDurations *DynamodbAlertDurations `json:"dynamoDbAlertThresholds"`
|
|
}
|
|
|
|
type DynamodbAlertThresholds struct {
|
|
ThrottledRequest int `json:"throttledRequest"`
|
|
SystemError int `json:"systemError"`
|
|
}
|
|
|
|
type DynamodbAlertDurations struct {
|
|
ThrottledRequest int `json:"throttledRequest"`
|
|
SystemError int `json:"systemError"`
|
|
}
|
|
|
|
type DynamoDbAutoScalingOptions struct {
|
|
MaxReadCapacity int `json:"maxReadCapacity"`
|
|
MinReadCapacity int `json:"minReadCapacity"`
|
|
ReadTargetValue int `json:"readTargetValue"`
|
|
MaxWriteCapacity int `json:"maxWriteCapacity"`
|
|
MinWriteCapacity int `json:"minWriteCapacity"`
|
|
WriteTargetValue int `json:"writeTargetValue"`
|
|
}
|
|
|
|
type DynamodbGsi struct {
|
|
Name string `json:"name"`
|
|
ReadCapacity int `json:"readCapacity"`
|
|
WriteCapacity int `json:"writeCapacity"`
|
|
HashKey string `json:"hashKey"`
|
|
RangeKey string `json:"rangeKey"`
|
|
ProjectionType string `json:"projectionType"`
|
|
NonKeyAttributes []string `json:"nonKeyAttributes"`
|
|
AutoScalingOptions *DynamoDbAutoScalingOptions `json:"autoScaling"`
|
|
IsAutoScalingEnabled bool `json:"isAutoScalingEnabled"`
|
|
}
|
|
|
|
type DynamodbLsi struct {
|
|
Name string `json:"name"`
|
|
RangeKey string `json:"rangeKey"`
|
|
ProjectionType string `json:"projectionType"`
|
|
NonKeyAttributes []string `json:"nonKeyAttributes"`
|
|
}
|
|
|
|
// We provide defaults in respective terraforms instead of here to keep all values at one place
|
|
type Database struct {
|
|
DbEngineType string `json:"dbEnginetype"`
|
|
AwsInstanceClass string `json:"awsInstanceClass"`
|
|
PsqlEngineVersion string `json:"psqlEngineVersion"`
|
|
User string `json:"user" valid:"required"`
|
|
Password string `json:"password" valid:"required"`
|
|
SizeInGb int `json:"sizeInGb"`
|
|
StorageType string `json:"storageType"`
|
|
Iops int `json:"iops"`
|
|
StorageThroughput int `json:"storageThroughput"`
|
|
MaxAllocatedStorage int `json:"maxAllocatedStorageInGb"`
|
|
DbNames []string `json:"dbNames"`
|
|
InstanceName string `json:"instanceName" valid:"required"`
|
|
BackupDisabled bool `json:"backupDisabled"`
|
|
DRBackupDisable bool `json:"drBackupDisable"`
|
|
MultiAZDisabled bool `json:"multiAZDisabled"`
|
|
ApplyImmediately bool `json:"applyImmediately"`
|
|
DbExtensions []string `json:"dbExtensions"`
|
|
MonitoringUser string `env:"MONITORING_USER"`
|
|
MonitoringPassword string `env:"MONITORING_PASSWORD"`
|
|
ReadonlyUser string `json:"readonlyUser"`
|
|
ReadonlyPassword string `json:"readonlyPassword"`
|
|
PerformanceInsightsEnabled bool `json:"performanceInsightsEnabled"`
|
|
ReadReplica *ReadReplica `json:"readReplica"`
|
|
RdsAlertThresholds *RdsAlertThresholds `json:"rdsAlertThresholds"`
|
|
AuroraAlertThresholds *AuroraAlertThresholds `json:"auroraAlertThresholds"`
|
|
IoOptimised bool `json:"ioOptimised"`
|
|
Parameters []Parameter `json:"parameters"`
|
|
RdsAlertDurations *RdsAlertDurations `json:"rdsAlertDurations"`
|
|
AuroraAlertDurations *AuroraAlertDurations `json:"auroraAlertDurations"`
|
|
StorageEncrypted bool `json:"storageEncrypted"`
|
|
KmsKeyId string `json:"kmsKeyId"`
|
|
StatementTimeout int `json:"statementTimeout"`
|
|
TeleportUserStatementTimeout int `json:"teleportUserStatementTimeout"`
|
|
SnapshotIdentifier string `json:"snapshotIdentifier"`
|
|
}
|
|
|
|
type ElasticCache struct {
|
|
AwsInstanceClass string `json:"awsInstanceClass"`
|
|
InstanceName string `json:"instanceName" valid:"required"`
|
|
MultiAZ bool `json:"multiAZ"`
|
|
ApplyImmediately bool `json:"applyImmediately"`
|
|
EngineVersion string `json:"engineVersion"`
|
|
KmsKeyId *string `json:"kmsKeyId"`
|
|
ClusterMode bool `json:"clusterMode,omitempty"`
|
|
NumNodeGroups int `json:"numberOfNodeGroups,omitempty"`
|
|
NumReplicasPerNodeGroup int `json:"numberOfReplicasPerGroup,omitempty"`
|
|
ElasticCacheAlertThresholds *ElasticCacheAlertThresholds `json:"elasticCacheAlertThresholds"`
|
|
ElasticCacheAlertDurations *ElasticCacheAlertDurations `json:"elasticCacheAlertDurations"`
|
|
}
|
|
|
|
type ElasticCacheAlertDurations struct {
|
|
CpuUtilization int `json:"cpuUtilization"`
|
|
CpuCreditBalance int `json:"cpuCreditBalance"`
|
|
MemoryUsage int `json:"memoryUsage"`
|
|
NetworkBandwidthInAllowanceExceeded int `json:"networkBandwidthInAllowanceExceeded"`
|
|
NetworkBandwidthOutAllowanceExceeded int `json:"networkBandwidthOutAllowanceExceeded"`
|
|
NetworkBandwidthTrackedAllowanceExceeded int `json:"networkBandwidthTrackedAllowanceExceeded"`
|
|
}
|
|
|
|
type ElasticCacheAlertThresholds struct {
|
|
CpuUtilization int `json:"cpuUtilization"`
|
|
CpuCreditBalance int `json:"cpuCreditBalance"`
|
|
MemoryUsage int `json:"memoryUsage"`
|
|
NetworkBandwidthInAllowanceExceeded int `json:"networkBandwidthInAllowanceExceeded"`
|
|
NetworkBandwidthOutAllowanceExceeded int `json:"networkBandwidthOutAllowanceExceeded"`
|
|
NetworkBandwidthTrackedAllowanceExceeded int `json:"networkBandwidthTrackedAllowanceExceeded"`
|
|
}
|
|
|
|
type DocDb struct {
|
|
AwsInstanceClass string `json:"awsInstanceClass"`
|
|
InstanceName string `json:"instanceName" valid:"required"`
|
|
ApplyImmediately bool `json:"applyImmediately"`
|
|
MasterUser string `json:"masterUser" valid:"required"`
|
|
MasterPassword string `json:"masterPassword" valid:"required"`
|
|
Parameters []Parameter `json:"parameters"`
|
|
KmsKeyId string `json:"kmsKeyId"`
|
|
ClusterSize int `json:"clusterSize"`
|
|
DocDBAlertThresholds *DocDBAlertThresholds `json:"docDBAlertThresholds"`
|
|
DocDBAlertDurations *DocDBAlertDurations `json:"docDBAlertDurations"`
|
|
}
|
|
|
|
type DocDBAlertThresholds struct {
|
|
ReadLatency float64 `json:"readLatency"`
|
|
WriteLatency float64 `json:"writeLatency"`
|
|
DBConnections int `json:"dbConnections"`
|
|
CpuUtilization int `json:"cpuUtilization"`
|
|
CpuCreditBalance int `json:"cpuCreditBalance"`
|
|
VolumeUsageTooHigh int `json:"volumeUsageTooHigh"`
|
|
FreeMemoryTooLowInMB int `json:"freeMemoryTooLowInMB"`
|
|
}
|
|
|
|
type DocDBAlertDurations struct {
|
|
ReadLatency int `json:"readLatency"`
|
|
WriteLatency int `json:"writeLatency"`
|
|
DBConnections int `json:"dbConnections"`
|
|
CpuUtilization int `json:"cpuUtilization"`
|
|
CpuCreditBalance int `json:"cpuCreditBalance"`
|
|
VolumeUsageTooHigh int `json:"volumeUsageTooHigh"`
|
|
FreeMemoryTooLowInMB int `json:"freeMemoryTooLowInMB"`
|
|
}
|
|
|
|
type Parameter struct {
|
|
Name string `json:"name" valid:"required"`
|
|
Value string `json:"value" valid:"required"`
|
|
ApplyMethod string `json:"applyMethod"`
|
|
}
|
|
|
|
type Team struct {
|
|
Name string `json:"name"`
|
|
Owner string
|
|
Product string
|
|
}
|
|
|
|
type Policies struct {
|
|
Actions []string `json:"actions"`
|
|
Resource string `json:"resource" valid:"required,matches((^arn.*)|(^\\*$))~Policy resource must be an aws arn or *"`
|
|
}
|
|
|
|
type ServiceRole struct {
|
|
Policies []Policies `json:"policies"`
|
|
RoleName string `json:"roleName"`
|
|
}
|
|
|
|
type StateStoreBackend struct {
|
|
BucketName string
|
|
AWSProfile string
|
|
}
|
|
|
|
type S3Bucket struct {
|
|
BucketName string `json:"anonymizedBucketName" valid:"required"`
|
|
BucketTag string `json:"bucketTag" valid:"required"`
|
|
LifecycleRules []LifecycleRuleWithPathPrefix `json:"lifecycleRules"`
|
|
EnableAccessLog bool `json:"enableAccessLog"`
|
|
EnablePublicBucket bool `json:"enablePublicBucket"`
|
|
CorsPolicy []CorsRule `json:"corsPolicy,omitempty"`
|
|
BucketPolicy string `json:"bucketPolicy,omitempty"`
|
|
Metadata map[string]string `json:"metadata,omitempty"`
|
|
}
|
|
|
|
type RdsAlertThresholds struct {
|
|
CpuUtilization int `json:"cpuUtilization"`
|
|
CpuCreditBalance int `json:"cpuCreditBalance"`
|
|
BurstBalance int `json:"burstBalance"`
|
|
DBConnections int `json:"dbConnections"`
|
|
QueueDepth int `json:"queueDepth"`
|
|
FreeStorageSpacePercent int `json:"freeStorageSpacePercent"`
|
|
FreeMemoryTooLowInMB int `json:"freeMemoryTooLowInMB"`
|
|
ReadLatency float64 `json:"readLatency"`
|
|
WriteLatency float64 `json:"writeLatency"`
|
|
EBSByteBalance int `json:"ebsByteBalance"`
|
|
EBSIOBalance int `json:"ebsIOBalance"`
|
|
TotalIOPS int `json:"totalIOPS" `
|
|
}
|
|
|
|
type RdsAlertDurations struct {
|
|
CpuUtilization int `json:"cpuUtilization"`
|
|
CpuCreditBalance int `json:"cpuCreditBalance"`
|
|
BurstBalance int `json:"burstBalance"`
|
|
DBConnections int `json:"dbConnections"`
|
|
QueueDepth int `json:"queueDepth"`
|
|
FreeStorageSpacePercent int `json:"freeStorageSpacePercent"`
|
|
FreeMemoryTooLowInMB int `json:"freeMemoryTooLowInMB"`
|
|
ReadLatency int `json:"readLatency"`
|
|
WriteLatency int `json:"writeLatency"`
|
|
EBSByteBalance int `json:"ebsByteBalance"`
|
|
EBSIOBalance int `json:"ebsIOBalance"`
|
|
TotalIOPS int `json:"totalIOPS"`
|
|
}
|
|
|
|
type AuroraAlertThresholds struct {
|
|
CpuUtilization int `json:"cpuUtilization"`
|
|
CpuCreditBalance int `json:"cpuCreditBalance"`
|
|
DBConnections int `json:"dbConnections"`
|
|
QueueDepth int `json:"queueDepth"`
|
|
FreeMemoryTooLowInMB int `json:"freeMemoryTooLowInMB"`
|
|
ReplicaLag int `json:"replicaLag"`
|
|
ReadLatency float64 `json:"readLatency"`
|
|
WriteLatency float64 `json:"writeLatency"`
|
|
EBSByteBalance int `json:"ebsByteBalance"`
|
|
EBSIOBalance int `json:"ebsIOBalance"`
|
|
}
|
|
|
|
type AuroraAlertDurations struct {
|
|
CpuUtilization int `json:"cpuUtilization"`
|
|
CpuCreditBalance int `json:"cpuCreditBalance"`
|
|
DBConnections int `json:"dbConnections"`
|
|
QueueDepth int `json:"queueDepth"`
|
|
FreeMemoryTooLowInMB int `json:"freeMemoryTooLowInMB"`
|
|
ReplicaLag int `json:"replicaLag"`
|
|
ReadLatency int `json:"readLatency"`
|
|
WriteLatency int `json:"writeLatency"`
|
|
EBSByteBalance int `json:"ebsByteBalance"`
|
|
EBSIOBalance int `json:"ebsIOBalance"`
|
|
}
|
|
|
|
type LifecycleRuleWithPathPrefix struct {
|
|
PathPrefix string `json:"pathPrefix,omitempty"`
|
|
Expiration *LifecycleRule `json:"expiration,omitempty"`
|
|
Transition *LifecycleRule `json:"transition,omitempty"`
|
|
NoncurrentVersionExpiration *LifecycleRule `json:"noncurrent_version_expiration,omitempty"`
|
|
NoncurrentVersionTransition *LifecycleRule `json:"noncurrent_version_transition,omitempty"`
|
|
}
|
|
|
|
type LifecycleRule struct {
|
|
Days int `json:"days,omitempty"`
|
|
StorageClass string `json:"storageClass,omitempty"`
|
|
}
|
|
|
|
type CorsRule struct {
|
|
AllowedHeaders []string `json:"AllowedHeaders"`
|
|
AllowedMethods []string `json:"AllowedMethods"`
|
|
AllowedOrigins []string `json:"AllowedOrigins"`
|
|
}
|
|
|
|
type ReadReplica struct {
|
|
AwsInstanceClass string `json:"awsInstanceClass"`
|
|
PerformanceInsightsEnabled bool `json:"performanceInsightsEnabled"`
|
|
MultiAZDisabled bool `json:"multiAZDisabled"`
|
|
}
|
|
|
|
const (
|
|
RESOURCE_AWS_ROLES = "roles"
|
|
RESOURCE_S3_BUCKETS = "s3_buckets"
|
|
RESOURCE_ELASTIC_CACHE = "elasticCache"
|
|
RESOURCE_DOCDB = "docdb"
|
|
RESOURCE_DYNAMODB = "dynamodb"
|
|
RESOURCE_RDS = "rds"
|
|
RESOURCE_AURORADB = "auroradb"
|
|
)
|
|
|
|
const (
|
|
DIR_RDS_TF = "rds-tf"
|
|
DIR_ELASTIC_CACHE_TF = "elastic-cache-tf"
|
|
DIR_DOCDB_TF = "document-db-tf"
|
|
DIR_AWS_ROLES_TF = "aws-roles-tf"
|
|
DIR_S3_BUCKETS_TF = "aws-s3-bucket-tf"
|
|
DIR_DYNAMODB_TF = "dynamo-db-tf"
|
|
DIR_AURORADB_TF = "aurora-db-tf"
|
|
)
|
|
|
|
var InfraVerticals = map[string]string{
|
|
"amc": "amc-",
|
|
"navi-ppl": "navi-ppl-",
|
|
"sa": "sa-",
|
|
"navi-pay": "navi-pay-",
|
|
"insurance": "gi-",
|
|
"lending": "",
|
|
}
|
|
|
|
var templateDirMap = map[string]string{
|
|
DIR_RDS_TF: "DATABASE",
|
|
DIR_ELASTIC_CACHE_TF: "ELASTIC CACHE",
|
|
DIR_DOCDB_TF: "DOCUMENT DB",
|
|
DIR_AWS_ROLES_TF: "AWS ACCESS",
|
|
DIR_S3_BUCKETS_TF: "S3 BUCKETS",
|
|
DIR_DYNAMODB_TF: "DYNAMODB",
|
|
DIR_AURORADB_TF: "DATABASE",
|
|
}
|
|
|
|
type ExtraResourceData struct {
|
|
ResourceName string `json:"resourceName"`
|
|
IsDeployed bool `json:"isDeployed"`
|
|
}
|
|
|
|
type ExtraResourcesDeployment struct {
|
|
Database ExtraResourceData `json:"database"`
|
|
Dynamodb []ExtraResourceData `json:"dynamodb"`
|
|
ElasticCache ExtraResourceData `json:"elasticCache"`
|
|
DocDb ExtraResourceData `json:"docdb"`
|
|
S3Buckets []ExtraResourceData `json:"s3_buckets"`
|
|
AwsAccess ExtraResourceData `json:"aws_access"`
|
|
}
|