-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(codepipeline-actions): use IBaseService instead of BaseService in…
… EcsDeployActionProps (#6412) * use IService instead of BaseService * fromEc2ServiceArn -> fromEc2ServiceAttributes, fromFargateServiceArn -> fromFargateServiceAttributes * fix ci error * fix build error * avoid breaking changes * add IBaseService to implements of BaseService * change to ICluster, add serviceName * fix build error * fix build error * create ImportedBaseService, add some tests * remove unused module, rename test * fix build error * create fromServiceAtrributes, remove ImportedBaseService. Some tests * update comment, tests * update comments, tests Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
9858cdb
commit bed5357
Showing
8 changed files
with
354 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
packages/@aws-cdk/aws-ecs/lib/base/from-service-attributes.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { Construct, Resource, Stack } from '@aws-cdk/core'; | ||
import { IBaseService } from '../base/base-service'; | ||
import { ICluster } from '../cluster'; | ||
|
||
/** | ||
* The properties to import from the service. | ||
*/ | ||
export interface ServiceAttributes { | ||
/** | ||
* The cluster that hosts the service. | ||
*/ | ||
readonly cluster: ICluster; | ||
|
||
/** | ||
* The service ARN. | ||
* | ||
* @default - either this, or {@link serviceName}, is required | ||
*/ | ||
readonly serviceArn?: string; | ||
|
||
/** | ||
* The name of the service. | ||
* | ||
* @default - either this, or {@link serviceArn}, is required | ||
*/ | ||
readonly serviceName?: string; | ||
} | ||
|
||
export function fromServiceAtrributes(scope: Construct, id: string, attrs: ServiceAttributes): IBaseService { | ||
if ((attrs.serviceArn && attrs.serviceName) || (!attrs.serviceArn && !attrs.serviceName)) { | ||
throw new Error('You can only specify either serviceArn or serviceName.'); | ||
} | ||
|
||
const stack = Stack.of(scope); | ||
let name: string; | ||
let arn: string; | ||
if (attrs.serviceName) { | ||
name = attrs.serviceName as string; | ||
arn = stack.formatArn({ | ||
partition: stack.partition, | ||
service: 'ecs', | ||
region: stack.region, | ||
account: stack.account, | ||
resource: 'service', | ||
resourceName: name, | ||
}); | ||
} else { | ||
arn = attrs.serviceArn as string; | ||
name = stack.parseArn(arn).resourceName as string; | ||
} | ||
class Import extends Resource implements IBaseService { | ||
public readonly serviceArn = arn; | ||
public readonly serviceName = name; | ||
public readonly cluster = attrs.cluster; | ||
} | ||
return new Import(scope, id); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.