-
Notifications
You must be signed in to change notification settings - Fork 4k
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
fix(codedeploy): DeploymentGroup's physical name not propagated to Application #13582
Conversation
198c2e5
to
fdb8af8
Compare
@skinny85 Please review |
@@ -269,7 +269,7 @@ export class ServerDeploymentGroup extends ServerDeploymentGroupBase { | |||
physicalName: props.deploymentGroupName, | |||
}); | |||
|
|||
this.application = props.application || new ServerApplication(this, 'Application'); | |||
this.application = props.application || new ServerApplication(this, this.physicalName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the right fix for this issue. The fix is that if the parent DeploymentGroup
has a PhysicalName.GENERATE_IF_NEEDED
, so should the ServerApplication
.
The poster suggested as much under Expected Result.
Also the title of this PR doesn't cover the change it's making. The title as written makes it sound as if no Application was created before, whereas now there is. This is not true though, an Application was already being created before.
We generally also write the PR title in terms of things the user would care about, and specifically for fixes it describes the bug that is now fixed (users will see these titles in the CHANGELOG, so think about what would make sense to them when viewed there).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rix0rrr Thanks for the review. I made the changes. Please have a look
@@ -4,6 +4,7 @@ import * as ec2 from '@aws-cdk/aws-ec2'; | |||
import * as iam from '@aws-cdk/aws-iam'; | |||
import * as s3 from '@aws-cdk/aws-s3'; | |||
import * as cdk from '@aws-cdk/core'; | |||
import { isGeneratedWhenNeededMarker } from '@aws-cdk/core/lib/private/physical-name-generator'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't import this in this way. This looks like it's a private function. Either import from @aws-cdk/core
directory, or if it's not exported there, you can't import this at all.
I'm guessing name == PhysicalName.GENERATE_IF_NEEDED
should just work, did you try that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I initially tried cdk.PhysicalName.GENERATE_IF_NEEDED
. But after going through the logic resides inside the resources.ts file, I came up with this logic :) I hope name == PhysicalName.GENERATE_IF_NEEDED
would work fine. will changes that
@@ -269,7 +270,11 @@ export class ServerDeploymentGroup extends ServerDeploymentGroupBase { | |||
physicalName: props.deploymentGroupName, | |||
}); | |||
|
|||
this.application = props.application || new ServerApplication(this, 'Application'); | |||
if (props.deploymentGroupName && isGeneratedWhenNeededMarker(props.deploymentGroupName)) { | |||
this.application = new ServerApplication(this, this.physicalName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are changing the construct ID, not the resource name. The construct ID needs to stay consistent (and cannot be a token). The resource name is a property and CAN be a token.
The pattern always looks like this:
new Resource(this, 'ResourceId', { // <--- id
resourceName: 'resourceName' // <--- name
});
deploymentGroupName: physical_name, | ||
}); | ||
|
||
test.notEqual(deploymentGroup, undefined); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test you want to write here is that there is an AWS::CodeDeploy::Application
with a specific ApplicationName
property.
Look into using haveResource
assertions.
@rix0rrr Please review |
deploymentGroupName: cdk.PhysicalName.GENERATE_IF_NEEDED, | ||
}); | ||
|
||
expect(stack).to(haveResource('AWS::CodeDeploy::DeploymentGroup', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to be asserting something about the AWS::CodeDeploy::Application
, not the DeploymentGroup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yuh, but there won't be a field called ApplicationName
in the output. That fails the build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then the issue is not fixed. That is what the desired output needs to be.
If it's not that, then we need to change code until it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Field ApplicationName missing in:
{
"Type": "AWS::CodeDeploy::Application",
"Properties": {
"ComputePlatform": "Server"
}
}
output for the test case with the resource type AWS::CodeDeploy:;DeploymentGroup
. Same output will be received when the resource type of can be created by explicitly passing an Application
test changed
6f5622a
to
36020c4
Compare
}); | ||
|
||
expect(stack).to(haveResource('AWS::CodeDeploy::Application', { | ||
'ComputePlatform': 'Server', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do need an ApplicationName
provided here.
If it doesn't appear, then the fix is not sufficient. It may be the that the ServerApplication does not respect PhysicalNames, for example.
Try and step through the code to see where the discrepancy between what we expect and what actually happens comes from.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we give a custom name and check whether we'll be receiving the out as expected instead of a PhysicaName?
…plication with physical name if needed
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
fixes #13337
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license