Skip to content

Commit 46686cc

Browse files
authored
Merge pull request #205 from Anusha-janardhan/topic-release
feat(settings): added settings configuration in settings-config.json to support new products
2 parents 51778d6 + a82eb6f commit 46686cc

13 files changed

Lines changed: 4169 additions & 584 deletions
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
AWSTemplateFormatVersion: '2010-09-09'
2+
Description: >
3+
CloudFormation template to create a SageMaker Domain
4+
with an IAM execution role. Applies project_name tag.
5+
6+
Parameters:
7+
Namespace:
8+
Type: String
9+
Description: An environment name that will be prefixed to resource names
10+
VpcId:
11+
Type: AWS::EC2::VPC::Id
12+
Description: VPC where SageMaker domain will be created.
13+
SubnetId:
14+
Type: AWS::EC2::Subnet::Id
15+
Description: Subnet for the SageMaker domain.
16+
ProjectId:
17+
Description: Project Id that will be added as tag to the resources.
18+
Type: String
19+
20+
21+
Resources:
22+
SageMakerExecutionRole:
23+
Type: AWS::IAM::Role
24+
Properties:
25+
RoleName: !Sub "${Namespace}-SageMakerExecutionRole"
26+
AssumeRolePolicyDocument:
27+
Version: "2012-10-17"
28+
Statement:
29+
- Effect: Allow
30+
Principal:
31+
Service: sagemaker.amazonaws.com
32+
Action: sts:AssumeRole
33+
ManagedPolicyArns:
34+
- arn:aws:iam::aws:policy/AmazonSageMakerFullAccess
35+
- arn:aws:iam::aws:policy/AmazonS3FullAccess
36+
Tags:
37+
- Key: project_name
38+
Value: !Ref ProjectId
39+
- Key: cost_resource
40+
Value: !Ref "AWS::StackName"
41+
42+
43+
SageMakerDomain:
44+
Type: AWS::SageMaker::Domain
45+
Properties:
46+
AuthMode: IAM
47+
DomainName: !Sub "${Namespace}-sagemaker-domain"
48+
DefaultUserSettings:
49+
ExecutionRole: !GetAtt SageMakerExecutionRole.Arn
50+
SubnetIds:
51+
- !Ref SubnetId
52+
VpcId: !Ref VpcId
53+
Tags:
54+
- Key: project_name
55+
Value: !Ref ProjectId
56+
- Key: cost_resource
57+
Value: !Ref "AWS::StackName"
58+
59+
60+
Outputs:
61+
SageMakerDomainId:
62+
Description: ID of the created SageMaker Domain
63+
Value: !Ref SageMakerDomain
64+
65+
SageMakerExecutionRoleArn:
66+
Description: IAM role created for SageMaker
67+
Value: !GetAtt SageMakerExecutionRole.Arn

cft-templates/bedrock.yaml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
AWSTemplateFormatVersion: "2010-09-09"
2+
Description: >
3+
CloudFormation template to create a Bedrock Execution Role
4+
with a dummy parameter and a no-op resource for stack completion.
5+
6+
Parameters:
7+
EnvironmentName:
8+
Type: String
9+
Default: dev
10+
Description: Environment name (e.g., dev, qa, prod)
11+
12+
Resources:
13+
# Dummy Resource (no functional purpose, just to ensure a complete stack)
14+
DummyResource:
15+
Type: AWS::CloudFormation::WaitConditionHandle
16+
17+
# Bedrock Execution Role
18+
BedrockExecutionRole:
19+
Type: AWS::IAM::Role
20+
Properties:
21+
RoleName: !Sub "${AWS::StackName}-bedrock-execution-role"
22+
AssumeRolePolicyDocument:
23+
Version: "2012-10-17"
24+
Statement:
25+
- Effect: Allow
26+
Principal:
27+
Service: bedrock.amazonaws.com
28+
Action: sts:AssumeRole
29+
- Effect: Allow
30+
Principal:
31+
AWS: !Sub "arn:aws:iam::${AWS::AccountId}:root"
32+
Action:
33+
- sts:AssumeRole
34+
- sts:TagSession
35+
ManagedPolicyArns:
36+
- arn:aws:iam::aws:policy/AmazonBedrockFullAccess
37+
- arn:aws:iam::aws:policy/AmazonS3FullAccess
38+
Policies:
39+
- PolicyName: BedrockExecutionRolePolicy
40+
PolicyDocument:
41+
Version: "2012-10-17"
42+
Statement:
43+
- Effect: Allow
44+
Action:
45+
- "bedrock:*"
46+
Resource: "*"
47+
- Effect: Allow
48+
Action:
49+
- "s3:GetObject"
50+
- "s3:PutObject"
51+
- "s3:DeleteObject"
52+
- "s3:ListBucket"
53+
Resource: "*"
54+
- Effect: Allow
55+
Action:
56+
- "s3vectors:*"
57+
Resource: "*"
58+
- Effect: Allow
59+
Action:
60+
- "logs:CreateLogGroup"
61+
- "logs:CreateLogStream"
62+
- "logs:PutLogEvents"
63+
Resource: "*"
64+
- Effect: Allow
65+
Action:
66+
- "iam:CreateRole"
67+
- "iam:AttachRolePolicy"
68+
- "iam:PutRolePolicy"
69+
- "lambda:ListFunctions"
70+
- "lambda:GetFunction"
71+
- "lambda:InvokeFunction"
72+
- "iam:CreateRole"
73+
- "iam:GetRole"
74+
- "iam:PassRole"
75+
- "iam:ListAttachedRolePolicies"
76+
Resource: "*"
77+
- Effect: Allow
78+
Action:
79+
- "aoss:CreateCollection"
80+
- "aoss:ListCollections"
81+
- "aoss:BatchGetCollection"
82+
- "aoss:DeleteCollection"
83+
- "aoss:CreateAccessPolicy"
84+
- "aoss:GetAccessPolicy"
85+
- "aoss:ListAccessPolicies"
86+
- "aoss:UpdateAccessPolicy"
87+
- "aoss:DeleteAccessPolicy"
88+
- "aoss:CreateSecurityPolicy"
89+
- "aoss:GetSecurityPolicy"
90+
- "aoss:ListSecurityPolicies"
91+
- "aoss:UpdateSecurityPolicy"
92+
- "aoss:DeleteSecurityPolicy"
93+
Resource: "*"
94+
95+
Outputs:
96+
BedrockExecutionRoleArn:
97+
Description: ARN of the created Bedrock Execution Role
98+
Value: !GetAtt BedrockExecutionRole.Arn
99+
Export:
100+
Name: !Sub "${AWS::StackName}-BedrockExecutionRoleArn"
101+
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
Metadata:
2+
License: Apache-2.0
3+
AWSTemplateFormatVersion: '2010-09-09'
4+
Description: 'AWS CloudFormation Template to create an EC2 instance
5+
**WARNING** This template creates an Amazon EC2 instance and an Elastic IP Address.
6+
You will be billed for the AWS resources used if you create a stack from this template.'
7+
8+
Parameters:
9+
Namespace:
10+
Type: String
11+
Description: An environment name that will be prefixed to resource names
12+
S3Mounts:
13+
Type: String
14+
Description: A JSON array of objects with name, bucket, and prefix properties used to mount data
15+
IamPolicyDocument:
16+
Type: String
17+
Description: The IAM policy to be associated with the launched workstation
18+
EnvironmentInstanceFiles:
19+
Type: String
20+
Description: >-
21+
An S3 URI (starting with "s3://") that specifies the location of files to be copied to
22+
the environment instance, including any bootstrap scripts
23+
InstanceType:
24+
Description: Choose the instance type e.g t3.small (2vCPU , 2GiB RAM) t3.medium (2vCPU , 4GiB RAM), t3.large (2vCPU, 8GiB RAM).
25+
Type: String
26+
Default: t3.small
27+
AllowedValues: [t3.small, t3.medium, t3.large]
28+
ConstraintDescription: must be a valid EC2 instance type.
29+
EBSVolumeSize:
30+
Description: The initial size of the volume (in GBs) EBS will use for storage.
31+
Type: Number
32+
Default: 8
33+
KeyPair:
34+
Description: Name of an existing EC2 KeyPair to enable SSH access to the instance. If no key pairs exist, please create one from the button next to the dropdown. Please contact your Administrator if you are unable to create one.
35+
Type: AWS::EC2::KeyPair::KeyName
36+
ConstraintDescription: must be the name of an existing EC2 KeyPair.
37+
AllowedSSHLocation:
38+
Description: The IP address range that can be used to SSH to the EC2 instances
39+
Type: String
40+
MinLength: '9'
41+
MaxLength: '18'
42+
Default: 0.0.0.0/0
43+
AllowedPattern: (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2})
44+
ConstraintDescription: must be a valid IP CIDR range of the form x.x.x.x/x.
45+
LatestAmiId:
46+
Type: 'AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>'
47+
Default: '/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2'
48+
AvailabilityZone:
49+
Description: Select the availability zone in which to create the instance. If you plan to attach a secondary volume to the instance, create this instance in the same AvailabilityZone as the volume you created.
50+
Type: AWS::EC2::AvailabilityZone::Name
51+
52+
Conditions:
53+
IamPolicyEmpty: !Equals [!Ref IamPolicyDocument, '{}']
54+
55+
Resources:
56+
IAMRole:
57+
Type: 'AWS::IAM::Role'
58+
Properties:
59+
RoleName: !Join ['-', [Ref: Namespace, 'ec2-role']]
60+
Path: '/'
61+
AssumeRolePolicyDocument:
62+
Version: '2012-10-17'
63+
Statement:
64+
- Effect: 'Allow'
65+
Principal:
66+
Service:
67+
- 'ec2.amazonaws.com'
68+
Action:
69+
- 'sts:AssumeRole'
70+
Policies:
71+
- !If
72+
- IamPolicyEmpty
73+
- !Ref 'AWS::NoValue'
74+
- PolicyName: !Join ['-', [Ref: Namespace, 's3-studydata-policy']]
75+
PolicyDocument: !Ref IamPolicyDocument
76+
77+
InstanceProfile:
78+
Type: 'AWS::IAM::InstanceProfile'
79+
Properties:
80+
InstanceProfileName: !Join ['-', [Ref: Namespace, 'ec2-profile']]
81+
Path: '/'
82+
Roles:
83+
- Ref: IAMRole
84+
85+
EC2Instance:
86+
Type: AWS::EC2::Instance
87+
Properties:
88+
UserData:
89+
Fn::Base64: !Sub |
90+
#!/usr/bin/env bash
91+
exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
92+
# Download and execute bootstrap script
93+
aws s3 cp "${EnvironmentInstanceFiles}/get_bootstrap.sh" "/tmp"
94+
chmod 500 "/tmp/get_bootstrap.sh"
95+
/tmp/get_bootstrap.sh "${EnvironmentInstanceFiles}" '${S3Mounts}'
96+
97+
# Signal result to CloudFormation
98+
/opt/aws/bin/cfn-signal -e $? --stack "${AWS::StackName}" --resource "EC2Instance" --region "${AWS::Region}"
99+
InstanceType: !Ref 'InstanceType'
100+
AvailabilityZone: !Ref AvailabilityZone
101+
SecurityGroups: [!Ref 'InstanceSecurityGroup']
102+
KeyName: !Ref 'KeyPair'
103+
ImageId: !Ref 'LatestAmiId'
104+
IamInstanceProfile: !Ref InstanceProfile
105+
PropagateTagsToVolumeOnCreation: true
106+
BlockDeviceMappings:
107+
- DeviceName: /dev/xvda
108+
Ebs:
109+
VolumeSize: !Ref EBSVolumeSize
110+
Encrypted: true
111+
Tags:
112+
- Key: Name
113+
Value: !Join ['-', [Ref: Namespace, 'ec2-linux']]
114+
- Key: Description
115+
Value: EC2 workspace instance
116+
- Key: cost_resource
117+
Value: !Sub ${AWS::StackName}
118+
119+
InstanceSecurityGroup:
120+
Type: AWS::EC2::SecurityGroup
121+
Properties:
122+
GroupDescription: Enable SSH access
123+
SecurityGroupIngress:
124+
- IpProtocol: tcp
125+
FromPort: '22'
126+
ToPort: '22'
127+
CidrIp: !Ref 'AllowedSSHLocation'
128+
129+
Outputs:
130+
InstanceId:
131+
Description: InstanceId of the newly created EC2 instance
132+
Value: !Ref 'EC2Instance'
133+
InstanceIPAddress:
134+
Description: IP address of the newly created EC2 instance
135+
Value: !GetAtt [EC2Instance, PublicIp]
136+
InstanceDNSName:
137+
Description: DNS name of the newly created EC2 instance
138+
Value: !GetAtt [EC2Instance, PublicDnsName]
139+
AvailabilityZone:
140+
Description: AvailabilityZone of newly created EC2 instance
141+
Value: !Ref AvailabilityZone

0 commit comments

Comments
 (0)