-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into sagemaker-l2
- Loading branch information
Showing
31 changed files
with
568 additions
and
176 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
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
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
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
Oops, something went wrong.