Skip to content

Commit

Permalink
chore(elasticsearch): fix broken integration test (#21616)
Browse files Browse the repository at this point in the history
This test requires a service linked role in order for it to build the VPC and related resources. This adds that.


----

### All Submissions:

* [ ] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
TheRealAmazonKendra authored Aug 16, 2022
1 parent e53c4f7 commit ae5aceb
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 14 deletions.
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-elasticsearch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"@aws-cdk/assertions": "0.0.0",
"@aws-cdk/cdk-build-tools": "0.0.0",
"@aws-cdk/integ-runner": "0.0.0",
"@aws-cdk/integ-tests": "0.0.0",
"@aws-cdk/cfn2ts": "0.0.0",
"@aws-cdk/pkglint": "0.0.0",
"@types/jest": "^27.5.2"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
{
"Resources": {
"ServiceLinkedRole": {
"Type": "AWS::IAM::ServiceLinkedRole",
"Properties": {
"AWSServiceName": "es.amazonaws.com",
"Description": "Role for ElasticSearch VPC Test"
}
},
"Vpc8378EB38": {
"Type": "AWS::EC2::VPC",
"Properties": {
Expand Down Expand Up @@ -397,7 +404,10 @@
"VpcId": {
"Ref": "Vpc8378EB38"
}
}
},
"DependsOn": [
"ServiceLinkedRole"
]
},
"Domain66AC69E0": {
"Type": "AWS::Elasticsearch::Domain",
Expand Down Expand Up @@ -450,6 +460,9 @@
]
}
},
"DependsOn": [
"ServiceLinkedRole"
],
"UpdateReplacePolicy": "Delete",
"DeletionPolicy": "Delete"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"17.0.0"}
{"version":"20.0.0"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
{
"version": "20.0.0",
"testCases": {
"integ.elasticsearch-vpc": {
"cdk-integ-elasticsearch-vpc-test/DefaultTest": {
"stacks": [
"cdk-integ-elasticsearch-vpc"
],
"diffAssets": false,
"stackUpdateWorkflow": true
"assertionStack": "cdkintegelasticsearchvpctestDefaultTestDeployAssert0B044175"
}
},
"synthContext": {},
"enableLookups": false
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "17.0.0",
"version": "20.0.0",
"artifacts": {
"Tree": {
"type": "cdk:tree",
Expand All @@ -15,6 +15,12 @@
"validateOnSynth": false
},
"metadata": {
"/cdk-integ-elasticsearch-vpc/ServiceLinkedRole": [
{
"type": "aws:cdk:logicalId",
"data": "ServiceLinkedRole"
}
],
"/cdk-integ-elasticsearch-vpc/Vpc/Resource": [
{
"type": "aws:cdk:logicalId",
Expand Down Expand Up @@ -167,6 +173,15 @@
]
},
"displayName": "cdk-integ-elasticsearch-vpc"
},
"cdkintegelasticsearchvpctestDefaultTestDeployAssert0B044175": {
"type": "aws:cloudformation:stack",
"environment": "aws://unknown-account/unknown-region",
"properties": {
"templateFile": "cdkintegelasticsearchvpctestDefaultTestDeployAssert0B044175.template.json",
"validateOnSynth": false
},
"displayName": "cdk-integ-elasticsearch-vpc-test/DefaultTest/DeployAssert"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,22 @@
"id": "Tree",
"path": "Tree",
"constructInfo": {
"fqn": "@aws-cdk/core.Construct",
"version": "0.0.0"
"fqn": "constructs.Construct",
"version": "10.1.71"
}
},
"cdk-integ-elasticsearch-vpc": {
"id": "cdk-integ-elasticsearch-vpc",
"path": "cdk-integ-elasticsearch-vpc",
"children": {
"ServiceLinkedRole": {
"id": "ServiceLinkedRole",
"path": "cdk-integ-elasticsearch-vpc/ServiceLinkedRole",
"constructInfo": {
"fqn": "@aws-cdk/core.CfnResource",
"version": "0.0.0"
}
},
"Vpc": {
"id": "Vpc",
"path": "cdk-integ-elasticsearch-vpc/Vpc",
Expand Down Expand Up @@ -768,6 +776,42 @@
"fqn": "@aws-cdk/core.Stack",
"version": "0.0.0"
}
},
"cdk-integ-elasticsearch-vpc-test": {
"id": "cdk-integ-elasticsearch-vpc-test",
"path": "cdk-integ-elasticsearch-vpc-test",
"children": {
"DefaultTest": {
"id": "DefaultTest",
"path": "cdk-integ-elasticsearch-vpc-test/DefaultTest",
"children": {
"Default": {
"id": "Default",
"path": "cdk-integ-elasticsearch-vpc-test/DefaultTest/Default",
"constructInfo": {
"fqn": "constructs.Construct",
"version": "10.1.71"
}
},
"DeployAssert": {
"id": "DeployAssert",
"path": "cdk-integ-elasticsearch-vpc-test/DefaultTest/DeployAssert",
"constructInfo": {
"fqn": "@aws-cdk/core.Stack",
"version": "0.0.0"
}
}
},
"constructInfo": {
"fqn": "@aws-cdk/integ-tests.IntegTestCase",
"version": "0.0.0"
}
}
},
"constructInfo": {
"fqn": "@aws-cdk/integ-tests.IntegTest",
"version": "0.0.0"
}
}
},
"constructInfo": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
import * as ec2 from '@aws-cdk/aws-ec2';
import { App, Stack, StackProps, RemovalPolicy } from '@aws-cdk/core';
import { App, Stack, StackProps, RemovalPolicy, CfnResource } from '@aws-cdk/core';
import * as integ from '@aws-cdk/integ-tests';
import { Construct } from 'constructs';
import * as es from '../lib';

class TestStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);

const serviceLinkedRole = new CfnResource(this, 'ServiceLinkedRole', {
type: 'AWS::IAM::ServiceLinkedRole',
properties: {
AWSServiceName: 'es.amazonaws.com',
Description: 'Role for ElasticSearch VPC Test',
},
});

const vpc = new ec2.Vpc(this, 'Vpc');
const domainProps: es.DomainProps = {
version: es.ElasticsearchVersion.V7_1,
Expand All @@ -19,10 +28,14 @@ class TestStack extends Stack {
dataNodes: 2,
},
};
new es.Domain(this, 'Domain', domainProps);
const domain = new es.Domain(this, 'Domain', domainProps);
domain.node.addDependency(serviceLinkedRole);
}
}

const app = new App();
new TestStack(app, 'cdk-integ-elasticsearch-vpc');
const testCase = new TestStack(app, 'cdk-integ-elasticsearch-vpc');
new integ.IntegTest(app, 'cdk-integ-elasticsearch-vpc-test', {
testCases: [testCase],
});
app.synth();

0 comments on commit ae5aceb

Please sign in to comment.