Skip to content
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

Lab 13 ecs #65

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions 13-ECS/Practice-13.1/commands.txt
@@ -0,0 +1,14 @@
#LOGIN USING get-login-password
aws ecr get-login-password --region us-east-1 --profile labs | docker login --username AWS --password-stdin 324320755747.dkr.ecr.us-east-1.amazonaws.com

docker tag nginx:latest 324320755747.dkr.ecr.us-east-1.amazonaws.com/ecr:latest

docker push 324320755747.dkr.ecr.us-east-1.amazonaws.com/ecr:latest

# LOGIN USING get-authorization-token
TOKEN=$(aws ecr get-authorization-token --profile labs --output text --query 'authorizationData[].authorizationToken')

curl -i -H "Authorization: Basic $TOKEN" https://324320755747.dkr.ecr.us-east-1.amazonaws.com/v2/ecr/tags/list

# Run the image
docker run --rm -it 324320755747.dkr.ecr.us-east-1.amazonaws.com/ecr:latest
63 changes: 63 additions & 0 deletions 13-ECS/Practice-13.1/ecr.yml
@@ -0,0 +1,63 @@
Description: An ECR Repository

Parameters:
repositoryName:
Description: Name for the ECR Repository
Type: String

Resources:
MyRepository:
Type: AWS::ECR::Repository
Properties:
RepositoryName: !Sub ${repositoryName}
ImageScanningConfiguration:
ScanOnPush: true
RepositoryPolicyText:
Version: "2012-10-17"
Statement:
-
Sid: AllowPushPull
Effect: Allow
Principal:
AWS:
- !Sub "arn:aws:iam::${AWS::AccountId}:user/desmond.ndambi.labs"
Action:
- "ecr:GetDownloadUrlForLayer"
- "ecr:BatchGetImage"
- "ecr:BatchCheckLayerAvailability"
- "ecr:PutImage"
- "ecr:InitiateLayerUpload"
- "ecr:UploadLayerPart"
- "ecr:CompleteLayerUpload"
LifecyclePolicy:
LifecyclePolicyText: |
{
"rules": [
{
"rulePriority": 2,
"description": "Expire images after a month",
"selection": {
"tagStatus": "any",
"countType": "sinceImagePushed",
"countUnit": "days",
"countNumber": 30
},
"action": { "type": "expire" }
},
{
"rulePriority": 1,
"description": "Keeps only one untagged image",
"selection": {
"tagStatus": "untagged",
"countType": "imageCountMoreThan",
"countNumber": 1
},
"action": { "type": "expire" }
}
]
}

Outputs:
MyRepository:
Description: The URI of the Repository
Value: !Sub "${AWS::AccountId}.dkr.ecr.${AWS::Region}.amazonaws.com/${repositoryName}"
6 changes: 6 additions & 0 deletions 13-ECS/Practice-13.1/parameter.json
@@ -0,0 +1,6 @@
[
{
"ParameterKey": "repositoryName",
"ParameterValue": "ecr"
}
]