Skip to content

Draft proposal; Support autoupdate in AWS Private operators #1870

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

Open
wants to merge 3 commits into
base: main
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/actions/build_aws_eif/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ runs:
cp ${{ steps.buildFolder.outputs.BUILD_FOLDER }}/identity_scope.txt ${ARTIFACTS_OUTPUT_DIR}/
cp ${{ steps.buildFolder.outputs.BUILD_FOLDER }}/version_number.txt ${ARTIFACTS_OUTPUT_DIR}/
cp ./scripts/aws/ec2.py ${ARTIFACTS_OUTPUT_DIR}/
cp ./scripts/aws/autoupdate.py ${ARTIFACTS_OUTPUT_DIR}/
cp ./scripts/confidential_compute.py ${ARTIFACTS_OUTPUT_DIR}/
cp ./scripts/aws/requirements.txt ${ARTIFACTS_OUTPUT_DIR}/
cp ./scripts/aws/proxies.host.yaml ${ARTIFACTS_OUTPUT_DIR}/
Expand All @@ -112,6 +113,7 @@ runs:
cp ./scripts/aws/logrotate/operator-logrotate.conf ${ARTIFACTS_OUTPUT_DIR}/
cp ./scripts/aws/logrotate/logrotate ${ARTIFACTS_OUTPUT_DIR}/
cp ./scripts/aws/logrotate/logrotateDaily ${ARTIFACTS_OUTPUT_DIR}/
cp ./scripts/aws/logrotate/autoupdate ${ARTIFACTS_OUTPUT_DIR}/
cp -r ./scripts/aws/config-server ${ARTIFACTS_OUTPUT_DIR}/

docker cp amazonlinux:/sockd ${ARTIFACTS_OUTPUT_DIR}/
Expand Down
57 changes: 56 additions & 1 deletion scripts/aws/UID_CloudFormation.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Parameters:
- integ
ImageId:
Type: AWS::EC2::Image::Id
Default: ami-example1234567890
Default: ami-0050e67a1af79f68f
TrustNetworkCidr:
Description: The IP address range that can be used to SSH and HTTPS to the EC2 instances
Type: String
Expand Down Expand Up @@ -136,6 +136,9 @@ Resources:
- 'kms:GenerateDataKey*'
- 'kms:Describe*'
Resource: '*'
Tags:
- Key: Project
Value: UID2
SSMKEYAlias:
Type: AWS::KMS::Alias
Properties:
Expand Down Expand Up @@ -164,6 +167,9 @@ Resources:
- Ref: DeployToEnvironment
- '"'
- '}'
Tags:
- Key: Project
Value: UID2
WorkerRole:
Type: 'AWS::IAM::Role'
Properties:
Expand All @@ -190,8 +196,41 @@ Resources:
- Effect: Allow
Action: 'secretsmanager:GetSecretValue'
Resource: !Sub 'arn:aws:secretsmanager:${AWS::Region}:${AWS::AccountId}:secret:uid2-config-stack-${AWS::StackName}*'
- Sid: EC2LaunchTemplateWrite
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More permissions needed to allow autoscaling and launch template access.

This can be made optional only if customer enables auto-update.

Effect: Allow
Action:
- 'ec2:CreateLaunchTemplateVersion'
Resource:
- !Sub
- 'arn:aws:ec2:${AWS::Region}:${AWS::AccountId}:launch-template/${LaunchTemplateId}'
- LaunchTemplateId: !Ref LaunchTemplate
- Sid: AutoScalingReadPermissions
Effect: Allow
Action:
- 'autoscaling:DescribeAutoScalingInstances'
- 'autoscaling:DescribeAutoScalingGroups'
- 'autoscaling:DescribeInstanceRefreshes'
Resource: '*'
- Sid: AutoScalingWritePermissions
Effect: Allow
Action:
- 'autoscaling:UpdateAutoScalingGroup'
- 'autoscaling:StartInstanceRefresh'
Resource: '*'
Condition:
StringEquals:
'aws:ResourceTag/Project': 'UID2'
- Sid: EC2DescribePermissions
Effect: Allow
Action:
- 'ec2:DescribeLaunchTemplates'
- 'ec2:DescribeLaunchTemplateVersions'
Resource: '*'
ManagedPolicyArns:
- 'arn:aws:iam::aws:policy/CloudWatchAgentServerPolicy'
Tags:
- Key: Project
Value: UID2
WorkerInstanceProfile:
Type: 'AWS::IAM::InstanceProfile'
Properties:
Expand Down Expand Up @@ -230,9 +269,13 @@ Resources:
CidrIp: 0.0.0.0/0
Description: "Allow Outbound DNS"
VpcId: !Ref VpcId
Tags:
- Key: Project
Value: UID2
LaunchTemplate:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding tags to all resources created, to have tag based IAM permissions.

Type: AWS::EC2::LaunchTemplate
Properties:
LaunchTemplateName: !Sub 'uid2-launch-template-${AWS::StackName}'
LaunchTemplateData:
BlockDeviceMappings:
- DeviceName: /dev/xvda
Expand Down Expand Up @@ -261,6 +304,15 @@ Resources:
HttpTokens: required # Enforces IMDSv2
HttpPutResponseHopLimit: 1
InstanceMetadataTags: enabled
TagSpecifications:
- ResourceType: instance
Tags:
- Key: Project
Value: UID2
- ResourceType: volume
Tags:
- Key: Project
Value: UID2
AutoScalingGroup:
Type: AWS::AutoScaling::AutoScalingGroup
DependsOn:
Expand All @@ -283,6 +335,9 @@ Resources:
- Key: Name
Value: 'UID2 Instance'
PropagateAtLaunch: true
- Key: Project
Value: UID2
PropagateAtLaunch: true
CreationPolicy:
ResourceSignal:
Count: 1
Expand Down
Loading