-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
CodePipeline ClusterName & ServiceName deployment using AWS CDK #4375
Comments
Thanks for opening the issue @markusl . The problem you're running into is that If you know the cluster name, you can just implement the import codepipeline = require('@aws-cdk/aws-codepipeline');
import events = require('@aws-cdk/aws-events');
import iam = require('@aws-cdk/aws-iam');
import { Construct } from '@aws-cdk/core';
export interface MyEcsDeployActionProps extends codepipeline.CommonAwsActionProps {
readonly input: codepipeline.Artifact;
readonly serviceName: string;
readonly clusterName: string
}
export class MyEcsDeployAction implements codepipeline.IAction {
public readonly actionProperties: codepipeline.ActionProperties;
private readonly props: MyEcsDeployActionProps;
constructor(props: MyEcsDeployActionProps) {
this.actionProperties = {
...props,
category: codepipeline.ActionCategory.DEPLOY,
provider: 'ECS',
artifactBounds: { minInputs: 1, maxInputs: 1, minOutputs: 0, maxOutputs: 0 },
inputs: [props.input],
};
this.props = props;
}
public bind(_scope: Construct, _stage: codepipeline.IStage, options: codepipeline.ActionBindOptions):
codepipeline.ActionConfig {
// you probably need all these permissions
options.role.addToPolicy(new iam.PolicyStatement({
actions: [
'ecs:DescribeServices',
'ecs:DescribeTaskDefinition',
'ecs:DescribeTasks',
'ecs:ListTasks',
'ecs:RegisterTaskDefinition',
'ecs:UpdateService',
],
resources: ['*']
}));
options.role.addToPolicy(new iam.PolicyStatement({
actions: ['iam:PassRole'],
resources: ['*'],
conditions: {
StringEqualsIfExists: {
'iam:PassedToService': [
'ec2.amazonaws.com',
'ecs-tasks.amazonaws.com',
],
}
}
}));
options.bucket.grantRead(options.role);
return {
configuration: {
ClusterName: this.props.clusterName,
ServiceName: this.props.serviceName,
// FileName is imagedefinitions.json by default
},
};
}
public onStateChange(name: string, target?: events.IRuleTarget, options?: events.RuleProps): events.Rule {
throw new Error("Method not implemented.");
}
} And you use it like so: pipeline.addStage({
stageName: 'UpdateDev',
actions: [
new MyEcsDeployAction({
actionName: 'Deploy',
serviceName: 'service-name',
clusterName: 'cluster-name',
input: buildOutput,
}),
],
}); Let me know if that helps! Thanks, |
@skinny85 thank you for quick response! We will use the provided workaround until this is natively supported in CDK. Regards, |
This is being worked on in #5939 |
Done in #6412 :) |
I'm trying to replicate following CloudFormation template using AWS CDK:
However, I'm not sure how I should construct
ecs.BaseService
to achieve the needed functionality. Is there a raw Cfn class that could be used for this?None of these combinations worked that I tried to use:
Proposed API:
Other
This is a 🚀 Feature Request
The text was updated successfully, but these errors were encountered: