Skip to content

Commit

Permalink
add repository in a different region for ecr integration tests
Browse files Browse the repository at this point in the history
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
  • Loading branch information
somtochiama committed Jul 12, 2023
1 parent b51c004 commit d21152a
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 0 deletions.
3 changes: 3 additions & 0 deletions oci/tests/integration/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# export AWS_ACCESS_KEY_ID=
# export AWS_SECRET_ACCESS_KEY=
# export AWS_REGION=us-east-2
## This terraform variable should be different from
## the region set above.
# export TF_VAR_cross_region=us-east-1
## This random value is needed for AWS only to prevent
## https://github.com/hashicorp/terraform-provider-aws/issues/19583 which
## happens when using dynamic "name" value in presence of more than one tag.
Expand Down
8 changes: 8 additions & 0 deletions oci/tests/integration/aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ func registryLoginECR(ctx context.Context, output map[string]*tfjson.StateOutput
}
testRepos["ecr"] = testRepoURL

// test the cross-region repository
cross_region := output["cross_region"].Value.(string)
testCrossRepo := output["ecr_cross_region_repository_url"].Value.(string)
if err := tftestenv.RegistryLoginECR(ctx, cross_region, testCrossRepo); err != nil {
return nil, err
}
testRepos["ecr_cross_region"] = testCrossRepo

// Log into the test app repository to be able to push to it.
// This image is not used in testing and need not be included in
// testRepos.
Expand Down
15 changes: 15 additions & 0 deletions oci/tests/integration/terraform/aws/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
provider "aws" {}

provider "aws" {
alias = "cross_region"
region = var.cross_region
}

locals {
name = "flux-test-${var.rand}"
}
Expand All @@ -18,6 +23,16 @@ module "test_ecr" {
tags = var.tags
}

module "test_ecr_cross_reg" {
source = "git::https://github.com/fluxcd/test-infra.git//tf-modules/aws/ecr"

name = "test-repo-${local.name}-cross-reg"
tags = var.tags
providers = {
aws = aws.cross_region
}
}

module "test_app_ecr" {
source = "git::https://github.com/fluxcd/test-infra.git//tf-modules/aws/ecr"

Expand Down
9 changes: 9 additions & 0 deletions oci/tests/integration/terraform/aws/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,19 @@ output "region" {
value = module.eks.region
}

output "cross_region" {
value = var.cross_region
}


output "ecr_repository_url" {
value = module.test_ecr.repository_url
}

output "ecr_cross_region_repository_url" {
value = module.test_ecr_cross_reg.repository_url
}

output "ecr_registry_id" {
value = module.test_ecr.registry_id
}
Expand Down
5 changes: 5 additions & 0 deletions oci/tests/integration/terraform/aws/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ variable "tags" {
type = map(string)
default = {}
}

variable "cross_region" {
type = string
description = "different region for testing cross region resources"
}

0 comments on commit d21152a

Please sign in to comment.