Search code examples
pythonamazon-ecsaws-cdk

How to import the existing ECS Service into code_pipeline using cdk python


After I deployed ECS Cluster using EC2 instances.

Now I would like to write code_pipeline for deploying service to ECS Service cluster.

deploy_actions = aws_codepipeline_actions.EcsDeployAction(
                action_name="DeployAction",
                service=ecs.IBaseService(cluster=cluster_name,service=service_name),
                input=build_output,
            )

Cluster_name and ecs service_name have already existed.

I would like to import the existing cluster and service into code_pipeline using cdk python.

But it does not work.

Please guild me how to define service=ecs.IBaseService


Solution

  • There is a method to import an existing ECS cluster from_cluster_attributes.

    CDK has multiple issues or defects so it may not work. For instance, from method to import an existing VPC did not work (not sure if it has been fixed).