Class Repository
Define an ECR repository.
Inherited Members
Namespace: Amazon.CDK.AWS.ECR
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class Repository : RepositoryBase, IRepository, IResource, IRepositoryRef, IConstruct, IDependable, IEnvironmentAware
Syntax (vb)
Public Class Repository Inherits RepositoryBase Implements IRepository, IResource, IRepositoryRef, IConstruct, IDependable, IEnvironmentAware
Remarks
ExampleMetadata: fixture=default infused
Examples
var repository = new Repository(this, "TestRepository");
var runtime = new Runtime(this, "Runtime", new RuntimeProps {
AgentRuntimeArtifact = AgentRuntimeArtifact.FromEcrRepository(repository, "v1.0.0")
});
new MetricFilter(this, "ToolErrors", new MetricFilterProps {
LogGroup = runtime.ApplicationLogGroup,
FilterPattern = FilterPattern.StringValue("$.tool_status", "=", "error"),
MetricNamespace = "MyApp",
MetricName = "ToolExecutionErrors"
});
Synopsis
Constructors
| Repository(Construct, string, IRepositoryProps?) | Define an ECR repository. |
Properties
| PROPERTY_INJECTION_ID | Uniquely identifies this class. |
| RepositoryArn | The ARN of the repository. |
| RepositoryName | The name of the repository. |
Methods
| AddLifecycleRule(ILifecycleRule) | Add a life cycle rule to the repository. |
| AddToResourcePolicy(PolicyStatement) | Add a policy statement to the repository's resource policy. |
| ArnForLocalRepository(string, IConstruct, string?) | Returns an ECR ARN for a repository that resides in the same account/region as the current stack. |
| FromLookup(Construct, string, IRepositoryLookupOptions) | Lookup an existing repository. |
| FromRepositoryArn(Construct, string, string) | Define an ECR repository. |
| FromRepositoryAttributes(Construct, string, IRepositoryAttributes) | Import a repository. |
| FromRepositoryName(Construct, string, string) | Define an ECR repository. |
Constructors
Repository(Construct, string, IRepositoryProps?)
Define an ECR repository.
public Repository(Construct scope, string id, IRepositoryProps? props = null)
Parameters
- scope Construct
- id string
- props IRepositoryProps
Remarks
ExampleMetadata: fixture=default infused
Examples
var repository = new Repository(this, "TestRepository");
var runtime = new Runtime(this, "Runtime", new RuntimeProps {
AgentRuntimeArtifact = AgentRuntimeArtifact.FromEcrRepository(repository, "v1.0.0")
});
new MetricFilter(this, "ToolErrors", new MetricFilterProps {
LogGroup = runtime.ApplicationLogGroup,
FilterPattern = FilterPattern.StringValue("$.tool_status", "=", "error"),
MetricNamespace = "MyApp",
MetricName = "ToolExecutionErrors"
});
Properties
PROPERTY_INJECTION_ID
Uniquely identifies this class.
public static string PROPERTY_INJECTION_ID { get; }
Property Value
Remarks
ExampleMetadata: fixture=default infused
RepositoryArn
The ARN of the repository.
public override string RepositoryArn { get; }
Property Value
Overrides
Remarks
ExampleMetadata: fixture=default infused
RepositoryName
The name of the repository.
public override string RepositoryName { get; }
Property Value
Overrides
Remarks
ExampleMetadata: fixture=default infused
Methods
AddLifecycleRule(ILifecycleRule)
Add a life cycle rule to the repository.
public virtual void AddLifecycleRule(ILifecycleRule rule)
Parameters
- rule ILifecycleRule
Remarks
Life cycle rules automatically expire images from the repository that match certain conditions.
AddToResourcePolicy(PolicyStatement)
Add a policy statement to the repository's resource policy.
public override IAddToResourcePolicyResult AddToResourcePolicy(PolicyStatement statement)
Parameters
- statement PolicyStatement
Returns
Overrides
Remarks
While other resources policies in AWS either require or accept a resource section, Cfn for ECR does not allow us to specify a resource policy. It will fail if a resource section is present at all.
ArnForLocalRepository(string, IConstruct, string?)
Returns an ECR ARN for a repository that resides in the same account/region as the current stack.
public static string ArnForLocalRepository(string repositoryName, IConstruct scope, string? account = null)
Parameters
Returns
Remarks
ExampleMetadata: fixture=default infused
FromLookup(Construct, string, IRepositoryLookupOptions)
Lookup an existing repository.
public static IRepository FromLookup(Construct scope, string id, IRepositoryLookupOptions options)
Parameters
- scope Construct
- id string
- options IRepositoryLookupOptions
Returns
Remarks
ExampleMetadata: fixture=default infused
FromRepositoryArn(Construct, string, string)
Define an ECR repository.
public static IRepository FromRepositoryArn(Construct scope, string id, string repositoryArn)
Parameters
Returns
Remarks
ExampleMetadata: fixture=default infused
Examples
var repository = new Repository(this, "TestRepository");
var runtime = new Runtime(this, "Runtime", new RuntimeProps {
AgentRuntimeArtifact = AgentRuntimeArtifact.FromEcrRepository(repository, "v1.0.0")
});
new MetricFilter(this, "ToolErrors", new MetricFilterProps {
LogGroup = runtime.ApplicationLogGroup,
FilterPattern = FilterPattern.StringValue("$.tool_status", "=", "error"),
MetricNamespace = "MyApp",
MetricName = "ToolExecutionErrors"
});
FromRepositoryAttributes(Construct, string, IRepositoryAttributes)
Import a repository.
public static IRepository FromRepositoryAttributes(Construct scope, string id, IRepositoryAttributes attrs)
Parameters
- scope Construct
- id string
- attrs IRepositoryAttributes
Returns
Remarks
ExampleMetadata: fixture=default infused
FromRepositoryName(Construct, string, string)
Define an ECR repository.
public static IRepository FromRepositoryName(Construct scope, string id, string repositoryName)
Parameters
Returns
Remarks
ExampleMetadata: fixture=default infused
Examples
var repository = new Repository(this, "TestRepository");
var runtime = new Runtime(this, "Runtime", new RuntimeProps {
AgentRuntimeArtifact = AgentRuntimeArtifact.FromEcrRepository(repository, "v1.0.0")
});
new MetricFilter(this, "ToolErrors", new MetricFilterProps {
LogGroup = runtime.ApplicationLogGroup,
FilterPattern = FilterPattern.StringValue("$.tool_status", "=", "error"),
MetricNamespace = "MyApp",
MetricName = "ToolExecutionErrors"
});