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

Bug? in default policy created by CodeBuild with VPC config #2335

Closed
cjyclaire opened this issue Apr 19, 2019 · 3 comments · Fixed by #2506 or MechanicalRock/tech-radar#14 · May be fixed by MechanicalRock/cdk-constructs#5, MechanicalRock/cdk-constructs#6 or MechanicalRock/cdk-constructs#7
Labels
@aws-cdk/aws-codebuild Related to AWS CodeBuild bug This issue is a bug.

Comments

@cjyclaire
Copy link

https://github.com/awslabs/aws-cdk/blob/master/packages/%40aws-cdk/aws-codebuild/lib/project.ts#L900

`arn:aws:ec2:${Aws.region}:${Aws.accountId}:subnet/[[subnets]]`

instead of [[subnets]], it need to provide actually subnet-ids such as

`arn:aws:ec2:${Aws.region}:${Aws.accountId}:subnet/subnet-dsdas`
...

current policy generated will cause

9/18 | 12:43:58 PM | CREATE_FAILED        | AWS::CodeBuild::Project     | XXX (XXX0DDC635A) Not authorized to perform DescribeSecurityGroups (Service: AWSCodeBuild; Status Code: 400; Error Code: InvalidInputException; Request ID: 4e0ba4fa-6212-11e9-9b2d-15eae6919f60)

I'm guessing the policy content is invalid as when I tried with exact subnet ids, deploy will succeed.

@cjyclaire cjyclaire added the bug This issue is a bug. label Apr 19, 2019
@RomainMuller
Copy link
Contributor

Hey @cjyclaire,

Would you be able to provide a minimal reproduction of your problem? It'll help us solve it faster.

@RomainMuller RomainMuller added the @aws-cdk/aws-codebuild Related to AWS CodeBuild label Apr 23, 2019
@cjyclaire
Copy link
Author

cjyclaire commented Apr 23, 2019

you should be able to reproduce with a vpc and any codebuild project place in the private subnets of the vpc, such as:

// default vpc example
 const vpc = new ec2.VpcNetwork(this, 'Vpc', {
      maxAZs: 2,
      cidr: '10.0.0.0/21',
      enableDnsSupport: true,
      natGateways: 2,
      subnetConfiguration: [
        {
          cidrMask: 24,
          name: 'application',
          subnetType: ec2.SubnetType.Private
        },
        {
          cidrMask: 24,
          name: 'ingress',
          subnetType: ec2.SubnetType.Public
        },
        {
          cidrMask: 28,
          name: 'database',
          subnetType: ec2.SubnetType.Isolated
        },
      ],
    });

  const dbMigration = new codebuild.Project(this, '...', {
      source: new codebuild.CodeCommitSource({ repository: repo}),
      projectName: '...',
      description: '...',
      environment:{
        buildImage: codebuild.LinuxBuildImage.UBUNTU_14_04_RUBY_2_5_1
      },
      buildSpec: 'buildspec-db.yml',
      vpc: vpc,
      subnetSelection: {
        subnetType: ec2.SubnetType.Private
      }
    });

@skinny85
Copy link
Contributor

skinny85 commented May 7, 2019

Thanks for reporting @cjyclaire . Confirming this is a bug on our side.

skinny85 added a commit to skinny85/aws-cdk that referenced this issue May 9, 2019
skinny85 added a commit that referenced this issue May 10, 2019
SanderKnape pushed a commit to SanderKnape/aws-cdk that referenced this issue May 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment