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

fix: Support IService for EcsDeployAction #5939

Closed
wants to merge 0 commits into from
Closed

Conversation

ahammond
Copy link
Contributor

@ahammond ahammond commented Jan 23, 2020

Accept the IService interface instead of requiring BaseService


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@mergify
Copy link
Contributor

mergify bot commented Jan 23, 2020

Title does not follow the guidelines of Conventional Commits. Please adjust title before merge.

@ahammond ahammond changed the title Support IService for EcsDeployAction fix: Support IService for EcsDeployAction Jan 23, 2020
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

@skinny85 skinny85 left a comment

Choose a reason for hiding this comment

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

Thanks for the change @ahammond , but as you've probably seen, the situation is not as simple: IService does not have information about the cluster it's part of, which is something we need in this action.

I assume you want to use existing, imported services with this Action? A proper solution would probably require changes in the ECS module. If you're interested, we can talk about what needs to be done there :).

Thanks,
Adam

@ahammond
Copy link
Contributor Author

ahammond commented Feb 5, 2020

@skinny85 yeah, I saw it failed. I'd like to take a shot at it with some coaching.

@skinny85
Copy link
Contributor

skinny85 commented Feb 6, 2020

So here's the deal.

As the code shows, to be able to deploy an ECS service with the EcsDeployAction, we need two pieces of data from the service: its name, and the name of the cluster it belongs to. That's easy when the passed service is a newly created one, but becomes problematic when we want to use an imported one.

Both methods of importing existing services in ECS, for EC2 and Fargate variants, return a very anemic interface, IService, which only contains the service's ARN, not even its name! But anyway, even if name was there, we would still be missing the cluster.

But, the existing import methods, fromEc2ServiceArn and fromFargateServiceArn, have no way of providing the cluster. That's why we need new to create new ones, fromEc2ServiceAttributes and fromFargateServiceAttributes. Their return type needs to be a new interface, let's call it IBaseService, that adds cluster to the properties:

export interface IBaseService extends IService {
  readonly cluster: ICluster;
}

(we can't make cluster optional, because we want BaseService to implement IBaseService, and JSII does not allow changing the type of an overridden property)

We should also extend IService to include readonly serviceName: string (it can be parsed from the ECS service ARN).

After those changes in ECS are made, all that's left in EcsDeployAction is to change the type from BaseService to IBaseService. I think all these changes should be done in one PR (it will make it more obvious why are they needed).

Let me know if this description makes sense @ahammond , and if this sounds like something you'd be interested in implementing!

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants