Skip to content

Commit

Permalink
Merge pull request #30097 from hashicorp/td-teamcity-service-region
Browse files Browse the repository at this point in the history
Adds region overrides for services in TeamCity
  • Loading branch information
gdavison authored Mar 17, 2023
2 parents 9d45fe6 + 23f1167 commit 0420de2
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 20 deletions.
5 changes: 3 additions & 2 deletions .actrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Needed for testing our workflows
-P ubuntu-latest=ghcr.io/catthehacker/ubuntu:act-22.04
-P linux=ghcr.io/catthehacker/ubuntu:act-22.04
# The `full` variants are needed for Maven for TeamCity configuration validation
-P ubuntu-latest=ghcr.io/catthehacker/ubuntu:full-20.04
-P linux=ghcr.io/catthehacker/ubuntu:full-20.04
8 changes: 4 additions & 4 deletions .teamcity/components/generated/service_orgacct.kt
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
val orgacctServices = mapOf(
"accessanalyzer" to ServiceSpec("Access Analyzer"),
"accessanalyzer" to ServiceSpec("IAM Access Analyzer"),
"backup" to ServiceSpec("Backup", "TestAccBackupGlobalSettings_basic"),
"cloudformation" to ServiceSpec(
"CloudFormation",
"TestAccCloudFormationStackSet_PermissionModel_serviceManaged|TestAccCloudFormationStackSetInstance_deploymentTargets"
),
"cloudtrail" to ServiceSpec("CloudTrail"),
"config" to ServiceSpec("Config" /*"TestAccConfig_serial|TestAccConfigConfigurationAggregator_"*/),
"fms" to ServiceSpec("FMS"),
"fms" to ServiceSpec("FMS (Firewall Manager)", regionOverride = "us-east-1"),
"guardduty" to ServiceSpec("GuardDuty"),
"licensemanager" to ServiceSpec("License Manager"),
"macie2" to ServiceSpec("Macie2"),
"macie2" to ServiceSpec("Macie"),
"organizations" to ServiceSpec("Organizations"),
"securityhub" to ServiceSpec(
"SecurityHub",
"Security Hub",
"TestAccSecurityHub_serial/Account|TestAccSecurityHub_serial/OrganizationAdminAccount|TestAccSecurityHub_serial/OrganizationConfiguration"
),
)
14 changes: 7 additions & 7 deletions .teamcity/components/generated/services_all.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ val services = mapOf(
"configservice" to ServiceSpec("Config"),
"connect" to ServiceSpec("Connect"),
"controltower" to ServiceSpec("Control Tower"),
"cur" to ServiceSpec("Cost and Usage Report"),
"cur" to ServiceSpec("Cost and Usage Report", regionOverride = "us-east-1"),
"dataexchange" to ServiceSpec("Data Exchange"),
"datapipeline" to ServiceSpec("Data Pipeline"),
"datasync" to ServiceSpec("DataSync", vpcLock = true),
Expand All @@ -65,7 +65,7 @@ val services = mapOf(
"dynamodb" to ServiceSpec("DynamoDB"),
"ec2" to ServiceSpec("EC2 (Elastic Compute Cloud)", vpcLock = true),
"ecr" to ServiceSpec("ECR (Elastic Container Registry)"),
"ecrpublic" to ServiceSpec("ECR Public"),
"ecrpublic" to ServiceSpec("ECR Public", regionOverride = "us-east-1"),
"ecs" to ServiceSpec("ECS (Elastic Container)"),
"efs" to ServiceSpec("EFS (Elastic File System)", vpcLock = true),
"eks" to ServiceSpec("EKS (Elastic Kubernetes)", vpcLock = true),
Expand All @@ -82,7 +82,7 @@ val services = mapOf(
"evidently" to ServiceSpec("CloudWatch Evidently"),
"firehose" to ServiceSpec("Kinesis Firehose"),
"fis" to ServiceSpec("FIS (Fault Injection Simulator)"),
"fms" to ServiceSpec("FMS (Firewall Manager)"),
"fms" to ServiceSpec("FMS (Firewall Manager)", regionOverride = "us-east-1"),
"fsx" to ServiceSpec("FSx", vpcLock = true),
"gamelift" to ServiceSpec("GameLift"),
"glacier" to ServiceSpec("S3 Glacier"),
Expand Down Expand Up @@ -112,7 +112,7 @@ val services = mapOf(
"lambda" to ServiceSpec("Lambda", vpcLock = true),
"lexmodels" to ServiceSpec("Lex Model Building"),
"licensemanager" to ServiceSpec("License Manager"),
"lightsail" to ServiceSpec("Lightsail"),
"lightsail" to ServiceSpec("Lightsail", regionOverride = "us-east-1"),
"location" to ServiceSpec("Location"),
"logs" to ServiceSpec("CloudWatch Logs"),
"macie" to ServiceSpec("Macie Classic"),
Expand All @@ -136,7 +136,7 @@ val services = mapOf(
"outposts" to ServiceSpec("Outposts"),
"pinpoint" to ServiceSpec("Pinpoint"),
"pipes" to ServiceSpec("EventBridge Pipes"),
"pricing" to ServiceSpec("Pricing Calculator"),
"pricing" to ServiceSpec("Pricing Calculator", regionOverride = "us-east-1"),
"qldb" to ServiceSpec("QLDB (Quantum Ledger Database)"),
"quicksight" to ServiceSpec("QuickSight"),
"ram" to ServiceSpec("RAM (Resource Access Manager)"),
Expand All @@ -148,7 +148,7 @@ val services = mapOf(
"resourcegroups" to ServiceSpec("Resource Groups"),
"resourcegroupstaggingapi" to ServiceSpec("Resource Groups Tagging"),
"rolesanywhere" to ServiceSpec("Roles Anywhere"),
"route53" to ServiceSpec("Route 53", vpcLock = true),
"route53" to ServiceSpec("Route 53", vpcLock = true, regionOverride = "us-east-1"),
"route53domains" to ServiceSpec("Route 53 Domains"),
"route53recoverycontrolconfig" to ServiceSpec("Route 53 Recovery Control Config"),
"route53recoveryreadiness" to ServiceSpec("Route 53 Recovery Readiness"),
Expand Down Expand Up @@ -183,7 +183,7 @@ val services = mapOf(
"timestreamwrite" to ServiceSpec("Timestream Write"),
"transcribe" to ServiceSpec("Transcribe"),
"transfer" to ServiceSpec("Transfer Family", vpcLock = true),
"waf" to ServiceSpec("WAF Classic"),
"waf" to ServiceSpec("WAF Classic", regionOverride = "us-east-1"),
"wafregional" to ServiceSpec("WAF Classic Regional"),
"wafv2" to ServiceSpec("WAF"),
"worklink" to ServiceSpec("WorkLink"),
Expand Down
6 changes: 6 additions & 0 deletions .teamcity/components/service_build_config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ data class ServiceSpec(
val patternOverride: String? = null,
val vpcLock: Boolean = false,
val parallelismOverride: Int? = null,
val regionOverride: String? = null,
)

class Service(name: String, spec: ServiceSpec) {
Expand Down Expand Up @@ -37,6 +38,11 @@ class Service(name: String, spec: ServiceSpec) {
text("ACCTEST_PARALLELISM", spec.parallelismOverride.toString(), display = ParameterDisplay.HIDDEN)
}
}
if (spec.regionOverride != null) {
params {
text("env.AWS_DEFAULT_REGION", spec.regionOverride, display = ParameterDisplay.HIDDEN)
}
}

val serviceDir = "./internal/service/$packageName"
steps {
Expand Down
40 changes: 40 additions & 0 deletions internal/generate/teamcity/acctest_services.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ service "comprehend" {
parallelism = 10
}

service "cur" {
region = "us-east-1"
}

service "datasync" {
vpc_lock = true
}
Expand All @@ -51,6 +55,10 @@ service "ec2" {
vpc_lock = true
}

service "ecrpublic" {
region = "us-east-1"
}

service "efs" {
vpc_lock = true
}
Expand Down Expand Up @@ -83,6 +91,10 @@ service "emr" {
vpc_lock = true
}

service "fms" {
region = "us-east-1"
}

service "fsx" {
vpc_lock = true
}
Expand All @@ -91,10 +103,26 @@ service "kafka" {
vpc_lock = true
}

service "kendra" {
skip = true
}

service "kinesisanalytics" {
skip = true
}

service "kinesisanalyticsv2" {
skip = true
}

service "lambda" {
vpc_lock = true
}

service "lightsail" {
region = "us-east-1"
}

service "mq" {
vpc_lock = true
}
Expand All @@ -111,6 +139,10 @@ service "opsworks" {
vpc_lock = true
}

service "pricing" {
region = "us-east-1"
}

service "rds" {
vpc_lock = true
}
Expand All @@ -121,6 +153,9 @@ service "redshift" {

service "route53" {
vpc_lock = true

# Needed for Route 53 DNSSEC tests
region = "us-east-1"
}

service "route53resolver" {
Expand Down Expand Up @@ -151,6 +186,11 @@ service "transfer" {
vpc_lock = true
}

service "waf" {
region = "us-east-1"
}

service "workspaces" {
# Needed for logging configuration tests
vpc_lock = true
}
6 changes: 5 additions & 1 deletion internal/generate/teamcity/file.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

val services = mapOf(
{{- range .Services }}
"{{ .ProviderPackage }}" to ServiceSpec("{{ .HumanFriendly }}"{{ if .VpcLock }}, vpcLock = true{{ end }}{{ if ne .Parallelism 0 }}, parallelismOverride = {{ .Parallelism }}{{ end }}),
"{{ .ProviderPackage }}" to ServiceSpec("{{ .HumanFriendly }}"
{{- if .VpcLock }}, vpcLock = true{{ end -}}
{{- if ne .Parallelism 0 }}, parallelismOverride = {{ .Parallelism }}{{ end -}}
{{- if ne .Region "" }}, regionOverride = "{{ .Region }}"{{ end -}}
),
{{- end }}
)
15 changes: 9 additions & 6 deletions internal/generate/teamcity/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type ServiceDatum struct {
HumanFriendly string
VpcLock bool
Parallelism int
Region string
}

type TemplateData struct {
Expand Down Expand Up @@ -72,12 +73,6 @@ func main() {
p = l[names.ColProviderPackageActual]
}

// TODO: Remove this when we have a method for scheduling specific services
if p == "kendra" || p == "kinesisanalytics" || p == "kinesisanalyticsv2" {
g.Infof("Skipping service %q...", p)
continue
}

if _, err := os.Stat(fmt.Sprintf("../../service/%s", p)); err != nil || errors.Is(err, fs.ErrNotExist) {
continue
}
Expand All @@ -90,6 +85,12 @@ func main() {
if ok {
sd.VpcLock = serviceConfig.VpcLock
sd.Parallelism = serviceConfig.Parallelism
sd.Region = serviceConfig.Region
}

if serviceConfig.Skip {
g.Infof("Skipping service %q...", p)
continue
}

td.Services = append(td.Services, sd)
Expand Down Expand Up @@ -121,6 +122,8 @@ type acctestServiceConfig struct {
Service string `hcl:",label"`
VpcLock bool `hcl:"vpc_lock,optional"`
Parallelism int `hcl:"parallelism,optional"`
Skip bool `hcl:"skip,optional"`
Region string `hcl:"region,optional"`
}

func acctestConfigurations(filename string) (map[string]acctestServiceConfig, error) {
Expand Down

0 comments on commit 0420de2

Please sign in to comment.