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

tests/resource/codebuild_project: Fix hardcoded regions #16967

Merged
merged 4 commits into from
Jan 7, 2021

Conversation

YakDriver
Copy link
Member

@YakDriver YakDriver commented Jan 4, 2021

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Relates #12995 Phase 2

Release note for CHANGELOG:

NONE

Acceptance Tests GovCloud

Failures are unrelated and tracked elsewhere.

--- FAIL: TestAccAWSCodeBuildProject_ARMContainer (8.89s)
--- FAIL: TestAccAWSCodeBuildProject_Cache (57.36s)
--- FAIL: TestAccAWSCodeBuildProject_Environment_EnvironmentVariable_Type (77.34s)
--- FAIL: TestAccAWSCodeBuildProject_WindowsServer2019Container (14.79s)
--- PASS: TestAccAWSCodeBuildProject_Artifacts_ArtifactIdentifier (52.72s)
--- PASS: TestAccAWSCodeBuildProject_Artifacts_EncryptionDisabled (99.01s)
--- PASS: TestAccAWSCodeBuildProject_Artifacts_Location (66.58s)
--- PASS: TestAccAWSCodeBuildProject_Artifacts_Name (118.00s)
--- PASS: TestAccAWSCodeBuildProject_Artifacts_NamespaceType (56.88s)
--- PASS: TestAccAWSCodeBuildProject_Artifacts_OverrideArtifactName (58.34s)
--- PASS: TestAccAWSCodeBuildProject_Artifacts_Packaging (62.62s)
--- PASS: TestAccAWSCodeBuildProject_Artifacts_Path (73.76s)
--- PASS: TestAccAWSCodeBuildProject_Artifacts_Type (47.02s)
--- PASS: TestAccAWSCodeBuildProject_BadgeEnabled (36.15s)
--- PASS: TestAccAWSCodeBuildProject_basic (186.35s)
--- PASS: TestAccAWSCodeBuildProject_BuildTimeout (55.79s)
--- PASS: TestAccAWSCodeBuildProject_Description (54.35s)
--- PASS: TestAccAWSCodeBuildProject_EncryptionKey (219.16s)
--- PASS: TestAccAWSCodeBuildProject_Environment_Certificate (78.88s)
--- PASS: TestAccAWSCodeBuildProject_Environment_EnvironmentVariable (95.95s)
--- PASS: TestAccAWSCodeBuildProject_Environment_EnvironmentVariable_Value (137.60s)
--- PASS: TestAccAWSCodeBuildProject_Environment_RegistryCredential (57.70s)
--- PASS: TestAccAWSCodeBuildProject_LogsConfig_CloudWatchLogs (79.96s)
--- PASS: TestAccAWSCodeBuildProject_LogsConfig_S3Logs (104.39s)
--- PASS: TestAccAWSCodeBuildProject_QueuedTimeout (243.59s)
--- PASS: TestAccAWSCodeBuildProject_SecondaryArtifacts (241.21s)
--- PASS: TestAccAWSCodeBuildProject_SecondaryArtifacts_ArtifactIdentifier (85.26s)
--- PASS: TestAccAWSCodeBuildProject_SecondaryArtifacts_EncryptionDisabled (99.29s)
--- PASS: TestAccAWSCodeBuildProject_SecondaryArtifacts_Location (165.44s)
--- PASS: TestAccAWSCodeBuildProject_SecondaryArtifacts_NamespaceType (64.72s)
--- PASS: TestAccAWSCodeBuildProject_SecondaryArtifacts_OverrideArtifactName (65.23s)
--- PASS: TestAccAWSCodeBuildProject_SecondaryArtifacts_Packaging (137.84s)
--- PASS: TestAccAWSCodeBuildProject_SecondaryArtifacts_Path (73.27s)
--- PASS: TestAccAWSCodeBuildProject_SecondaryArtifacts_Type (47.31s)
--- PASS: TestAccAWSCodeBuildProject_SecondarySources_CodeCommit (45.27s)
--- PASS: TestAccAWSCodeBuildProject_SecondarySources_GitSubmodulesConfig_CodeCommit (207.66s)
--- PASS: TestAccAWSCodeBuildProject_SecondarySources_GitSubmodulesConfig_GitHub (84.59s)
--- PASS: TestAccAWSCodeBuildProject_SecondarySources_GitSubmodulesConfig_GitHubEnterprise (67.38s)
--- PASS: TestAccAWSCodeBuildProject_Source_GitCloneDepth (89.64s)
--- PASS: TestAccAWSCodeBuildProject_Source_GitSubmodulesConfig_CodeCommit (70.93s)
--- PASS: TestAccAWSCodeBuildProject_Source_GitSubmodulesConfig_GitHub (45.70s)
--- PASS: TestAccAWSCodeBuildProject_Source_GitSubmodulesConfig_GitHubEnterprise (84.62s)
--- PASS: TestAccAWSCodeBuildProject_Source_InsecureSSL (51.78s)
--- PASS: TestAccAWSCodeBuildProject_Source_ReportBuildStatus_Bitbucket (44.89s)
--- PASS: TestAccAWSCodeBuildProject_Source_ReportBuildStatus_GitHub (44.91s)
--- PASS: TestAccAWSCodeBuildProject_Source_ReportBuildStatus_GitHubEnterprise (50.30s)
--- PASS: TestAccAWSCodeBuildProject_Source_Type_Bitbucket (29.99s)
--- PASS: TestAccAWSCodeBuildProject_Source_Type_CodeCommit (36.72s)
--- PASS: TestAccAWSCodeBuildProject_Source_Type_CodePipeline (39.71s)
--- PASS: TestAccAWSCodeBuildProject_Source_Type_GitHubEnterprise (43.35s)
--- PASS: TestAccAWSCodeBuildProject_Source_Type_NoSource (54.46s)
--- PASS: TestAccAWSCodeBuildProject_Source_Type_NoSourceInvalid (14.45s)
--- PASS: TestAccAWSCodeBuildProject_Source_Type_S3 (49.23s)
--- PASS: TestAccAWSCodeBuildProject_SourceVersion (57.87s)
--- PASS: TestAccAWSCodeBuildProject_Tags (87.58s)
--- PASS: TestAccAWSCodeBuildProject_VpcConfig (79.45s)
--- SKIP: TestAccAWSCodeBuildProject_SecondaryArtifacts_Name (0.00s)

Acceptance Tests us-west-2

--- PASS: TestAccAWSCodeBuildProject_ARMContainer (31.25s)
--- PASS: TestAccAWSCodeBuildProject_Artifacts_ArtifactIdentifier (72.25s)
--- PASS: TestAccAWSCodeBuildProject_Artifacts_EncryptionDisabled (104.87s)
--- PASS: TestAccAWSCodeBuildProject_Artifacts_Location (279.63s)
--- PASS: TestAccAWSCodeBuildProject_Artifacts_Name (461.44s)
--- PASS: TestAccAWSCodeBuildProject_Artifacts_NamespaceType (67.05s)
--- PASS: TestAccAWSCodeBuildProject_Artifacts_OverrideArtifactName (60.95s)
--- PASS: TestAccAWSCodeBuildProject_Artifacts_Packaging (88.27s)
--- PASS: TestAccAWSCodeBuildProject_Artifacts_Path (227.05s)
--- PASS: TestAccAWSCodeBuildProject_Artifacts_Type (69.57s)
--- PASS: TestAccAWSCodeBuildProject_BadgeEnabled (34.95s)
--- PASS: TestAccAWSCodeBuildProject_basic (65.17s)
--- PASS: TestAccAWSCodeBuildProject_BuildTimeout (53.39s)
--- PASS: TestAccAWSCodeBuildProject_Cache (85.79s)
--- PASS: TestAccAWSCodeBuildProject_Description (54.45s)
--- PASS: TestAccAWSCodeBuildProject_EncryptionKey (29.38s)
--- PASS: TestAccAWSCodeBuildProject_Environment_Certificate (32.13s)
--- PASS: TestAccAWSCodeBuildProject_Environment_EnvironmentVariable (84.64s)
--- PASS: TestAccAWSCodeBuildProject_Environment_EnvironmentVariable_Type (83.74s)
--- PASS: TestAccAWSCodeBuildProject_Environment_EnvironmentVariable_Value (74.38s)
--- PASS: TestAccAWSCodeBuildProject_Environment_RegistryCredential (256.96s)
--- PASS: TestAccAWSCodeBuildProject_LogsConfig_CloudWatchLogs (69.46s)
--- PASS: TestAccAWSCodeBuildProject_LogsConfig_S3Logs (87.65s)
--- PASS: TestAccAWSCodeBuildProject_QueuedTimeout (50.55s)
--- PASS: TestAccAWSCodeBuildProject_SecondaryArtifacts (38.85s)
--- PASS: TestAccAWSCodeBuildProject_SecondaryArtifacts_ArtifactIdentifier (83.41s)
--- PASS: TestAccAWSCodeBuildProject_SecondaryArtifacts_EncryptionDisabled (78.55s)
--- PASS: TestAccAWSCodeBuildProject_SecondaryArtifacts_Location (93.74s)
--- PASS: TestAccAWSCodeBuildProject_SecondaryArtifacts_NamespaceType (89.79s)
--- PASS: TestAccAWSCodeBuildProject_SecondaryArtifacts_OverrideArtifactName (100.99s)
--- PASS: TestAccAWSCodeBuildProject_SecondaryArtifacts_Packaging (70.52s)
--- PASS: TestAccAWSCodeBuildProject_SecondaryArtifacts_Path (86.68s)
--- PASS: TestAccAWSCodeBuildProject_SecondaryArtifacts_Type (92.74s)
--- PASS: TestAccAWSCodeBuildProject_SecondarySources_CodeCommit (42.04s)
--- PASS: TestAccAWSCodeBuildProject_SecondarySources_GitSubmodulesConfig_CodeCommit (52.78s)
--- PASS: TestAccAWSCodeBuildProject_SecondarySources_GitSubmodulesConfig_GitHub (235.51s)
--- PASS: TestAccAWSCodeBuildProject_SecondarySources_GitSubmodulesConfig_GitHubEnterprise (46.58s)
--- PASS: TestAccAWSCodeBuildProject_Source_GitCloneDepth (131.25s)
--- PASS: TestAccAWSCodeBuildProject_Source_GitSubmodulesConfig_CodeCommit (91.12s)
--- PASS: TestAccAWSCodeBuildProject_Source_GitSubmodulesConfig_GitHub (68.39s)
--- PASS: TestAccAWSCodeBuildProject_Source_GitSubmodulesConfig_GitHubEnterprise (96.73s)
--- PASS: TestAccAWSCodeBuildProject_Source_InsecureSSL (67.58s)
--- PASS: TestAccAWSCodeBuildProject_Source_ReportBuildStatus_Bitbucket (99.47s)
--- PASS: TestAccAWSCodeBuildProject_Source_ReportBuildStatus_GitHub (144.73s)
--- PASS: TestAccAWSCodeBuildProject_Source_ReportBuildStatus_GitHubEnterprise (52.05s)
--- PASS: TestAccAWSCodeBuildProject_Source_Type_Bitbucket (38.06s)
--- PASS: TestAccAWSCodeBuildProject_Source_Type_CodeCommit (90.02s)
--- PASS: TestAccAWSCodeBuildProject_Source_Type_CodePipeline (88.85s)
--- PASS: TestAccAWSCodeBuildProject_Source_Type_GitHubEnterprise (36.98s)
--- PASS: TestAccAWSCodeBuildProject_Source_Type_NoSource (38.68s)
--- PASS: TestAccAWSCodeBuildProject_Source_Type_NoSourceInvalid (11.83s)
--- PASS: TestAccAWSCodeBuildProject_Source_Type_S3 (43.15s)
--- PASS: TestAccAWSCodeBuildProject_SourceVersion (30.70s)
--- PASS: TestAccAWSCodeBuildProject_Tags (39.73s)
--- PASS: TestAccAWSCodeBuildProject_VpcConfig (89.46s)
--- PASS: TestAccAWSCodeBuildProject_WindowsServer2019Container (155.55s)
--- SKIP: TestAccAWSCodeBuildProject_SecondaryArtifacts_Name (0.00s)

@YakDriver YakDriver requested a review from a team as a code owner January 4, 2021 23:31
@ghost ghost added size/XS Managed by automation to categorize the size of a PR. service/codebuild Issues and PRs that pertain to the codebuild service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Jan 4, 2021
@YakDriver YakDriver added the partition/aws-us-gov Pertains to the aws-us-gov partition. label Jan 4, 2021
@ghost ghost added size/XL Managed by automation to categorize the size of a PR. and removed size/XS Managed by automation to categorize the size of a PR. labels Jan 5, 2021
@bflad bflad self-assigned this Jan 7, 2021
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 🚀

My acceptance testing output matches yours.

Comment on lines -3401 to -3402
# InvalidInputException: CodeBuild currently doesn't support VPC in us-west-2d, please select subnets in other availability zones.
exclude_zone_ids = ["usw2-az4"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified this removal is safe via:

terraform {
  required_version = "0.14.3"

  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "3.22.0"
    }
  }
}

provider "aws" {
  region = "us-west-2"
}

resource "aws_iam_role" "test" {
  name = "16967-test"

  assume_role_policy = <<EOF
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "Service": "codebuild.amazonaws.com"
      },
      "Action": "sts:AssumeRole"
    }
  ]
}
EOF
}

resource "aws_iam_role_policy" "test" {
  role = aws_iam_role.test.name

  policy = <<POLICY
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Resource": [
        "*"
      ],
      "Action": [
        "logs:CreateLogGroup",
        "logs:CreateLogStream",
        "logs:PutLogEvents"
      ]
    },
    {
      "Effect": "Allow",
      "Action": [
        "ec2:CreateNetworkInterface",
        "ec2:DescribeDhcpOptions",
        "ec2:DescribeNetworkInterfaces",
        "ec2:DeleteNetworkInterface",
        "ec2:DescribeSubnets",
        "ec2:DescribeSecurityGroups",
        "ec2:DescribeVpcs"
      ],
      "Resource": "*"
    },
    {
      "Effect": "Allow",
      "Action": [
        "s3:*"
      ],
      "Resource": "*"
    }
  ]
}
POLICY
}

resource "aws_vpc" "test" {
  cidr_block = "10.0.0.0/16"
}

resource "aws_subnet" "test" {
  count = 1

  availability_zone_id = "usw2-az4"
  cidr_block           = "10.0.0.0/24"
  vpc_id               = aws_vpc.test.id

  tags = {
    Name = "tf-acc-codebuild-project"
  }
}

resource "aws_security_group" "test" {
  vpc_id = aws_vpc.test.id
}

resource "aws_codebuild_project" "test" {
  name         = "16967-test"
  service_role = aws_iam_role.test.arn

  artifacts {
    type = "NO_ARTIFACTS"
  }

  environment {
    compute_type = "BUILD_GENERAL1_SMALL"
    image        = "2"
    type         = "LINUX_CONTAINER"
  }

  source {
    location = "https://github.com/hashicorp/packer.git"
    type     = "GITHUB"
  }

  vpc_config {
    security_group_ids = [aws_security_group.test.id]
    subnets            = aws_subnet.test[*].id
    vpc_id             = aws_vpc.test.id
  }
}
$ terraform apply
...
aws_codebuild_project.test: Creating...
aws_codebuild_project.test: Creation complete after 6s [id=arn:aws:codebuild:us-west-2:--OMITTED--:project/16967-test]

Apply complete! Resources: 6 added, 0 changed, 0 destroyed.

@YakDriver YakDriver added this to the v3.23.0 milestone Jan 7, 2021
@YakDriver YakDriver merged commit eb8806d into master Jan 7, 2021
@YakDriver YakDriver deleted the t-gov-hardreg-codebuild branch January 7, 2021 20:33
@ghost
Copy link

ghost commented Jan 8, 2021

This has been released in version 3.23.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@ghost
Copy link

ghost commented Feb 7, 2021

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Feb 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
partition/aws-us-gov Pertains to the aws-us-gov partition. service/codebuild Issues and PRs that pertain to the codebuild service. size/XL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants