Skip to content

Commit

Permalink
[AWS] Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
JosepSampe committed May 29, 2024
1 parent e88b1f8 commit b99eb23
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 22 deletions.
2 changes: 1 addition & 1 deletion docs/source/compute_config/aws_batch.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ In summary, you can use one of the following settings:
| aws_batch | runtime_memory | 1024 | no | Runtime memory assigned to each task container. |
| aws_batch | runtime_cpu | 0.5 | no | Number of vCPUs assigned to each task container. It can be different from `worker_processes`. |
| aws_batch | worker_processes | 1 | no | Number of parallel Lithops processes in a worker. This is used to parallelize function activations within the worker. |
| aws_batch | service_role | `None` | no | Service role for AWS Batch. Leave empty to use a service-linked execution role. More info [here](https://docs.aws.amazon.com/batch/latest/userguide/using-service-linked-roles.html) |
| aws_batch | service_role | | no | Service role for AWS Batch. Leave empty to use a service-linked execution role. More info [here](https://docs.aws.amazon.com/batch/latest/userguide/using-service-linked-roles.html) |
| aws_batch | env_max_cpus | 10 | no | Maximum total CPUs of the compute environment |
| aws_batch | env_type | FARGATE_SPOT | no | Compute environment type, one of: `["EC2", "SPOT", "FARGATE", "FARGATE_SPOT"]` |

Expand Down
8 changes: 4 additions & 4 deletions docs/source/compute_config/aws_ec2.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ Alternatively, you can set the `reuse` mode to keep running the started worker V

4. Go back to **IAM** and navigate to **Roles** tab. Click **Create role**.

5. Choose **EC2** on the use case list. Click **Next: Permissions**. Select the policy created before (`lithops-policy`). Click **Next: Tags** and **Next: Review**. Type a role name, for example `lithops-ec2-execution-role`. Click on **Create Role**.
5. Choose **EC2** on the use case list. Click **Next: Permissions**. Select the policy created before (`lithops-policy`). Click **Next: Tags** and **Next: Review**. Type a role name, for example `ec2LithopsInstanceRole`. Click on **Create Role**.


### AWS Credential setup
Expand All @@ -138,7 +138,7 @@ In summary, you can use one of the following settings:
aws_ec2:
region : <REGION_NAME>
iam_role: <IAM_ROLE_NAME>
instance_role: <IAM_INSTANCE_ROLE_NAME>
exec_mode: reuse
```

Expand All @@ -153,7 +153,7 @@ In summary, you can use one of the following settings:
region: <REGION_NAME>
aws_ec2:
iam_role: <IAM_ROLE_NAME>
instance_role: <IAM_INSTANCE_ROLE_NAME>
exec_mode: reuse
```

Expand All @@ -172,7 +172,7 @@ In summary, you can use one of the following settings:
|Group|Key|Default|Mandatory|Additional info|
|---|---|---|---|---|
|aws_ec2 | region | |no | Region name, for example: `eu-west-1`. Lithops will use the `region` set under the `aws` section if it is not set here |
|aws_ec2 | iam_role | | yes | IAM EC2 role name. You can find it in the [IAM Console page](https://console.aws.amazon.com/iamv2/home#/roles). Create a new EC2 role if it does not exist. Do not use the full ARN here; only the role name is required|
|aws_ec2 | instance_role | | yes | EC2 Instance role name created in the configuration section above. Do not use the full ARN here; only the role name is required. For example: `ec2LithopsInstanceRole`|
|aws_ec2 | vpc_id | | no | VPC id. You can find all the available VPCs in the [VPC Console page](https://console.aws.amazon.com/vpc/v2/home#vpcs:) |
|aws_ec2 | subnet_id | | no | Subnet id. You can find all the available Subnets in the [VPC Console page](https://console.aws.amazon.com/vpc/v2/home#subnets:) |
|aws_ec2 | security_group_id | | no | Security group ID. You can find the available security groups in the [VPC console page](https://console.aws.amazon.com/vpc/v2/home#SecurityGroups:). The security group must have ports 22 and 8080 open |
Expand Down
19 changes: 6 additions & 13 deletions lithops/serverless/backends/aws_batch/aws_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,19 +144,12 @@ def _create_compute_env(self):
compute_resources_spec['minvCpus'] = 0
compute_resources_spec['instanceTypes'] = ['optimal']

if 'service_role' in self.aws_batch_config:
res = self.batch_client.create_compute_environment(
computeEnvironmentName=self._compute_env_name,
type='MANAGED',
computeResources=compute_resources_spec,
serviceRole=self.aws_batch_config['service_role']
)
else:
res = self.batch_client.create_compute_environment(
computeEnvironmentName=self._compute_env_name,
type='MANAGED',
computeResources=compute_resources_spec,
)
res = self.batch_client.create_compute_environment(
computeEnvironmentName=self._compute_env_name,
type='MANAGED',
computeResources=compute_resources_spec,
serviceRole=self.aws_batch_config.get('service_role', "")
)

if res['ResponseMetadata']['HTTPStatusCode'] != 200:
raise Exception(res)
Expand Down
2 changes: 1 addition & 1 deletion lithops/serverless/backends/aws_batch/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def load_config(config_data):

# container_vcpus is deprectaded. To be removed in a future release
if 'container_vcpus' in config_data['aws_batch']:
config_data['aws_batch']['runtime_cpu'] = config_data['aws_batch']['container_vcpus']
config_data['aws_batch']['runtime_cpu'] = config_data['aws_batch'].pop('container_vcpus')

if config_data['aws_batch']['env_type'] in {'FARGATE', 'FARGATE_SPOT'}:
runtime_memory = config_data['aws_batch']['runtime_memory']
Expand Down
4 changes: 2 additions & 2 deletions lithops/standalone/backends/aws_ec2/aws_ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ def init(self):
'master_id': self.vpc_key,
'vpc_name': self.vpc_name,
'vpc_id': self.config['vpc_id'],
'iam_role': self.config['iam_role'],
'instance_role': self.config['instance_role'],
'target_ami': self.config['target_ami'],
'ssh_key_name': self.config['ssh_key_name'],
'ssh_key_filename': self.config['ssh_key_filename'],
Expand Down Expand Up @@ -1174,7 +1174,7 @@ def _create_instance(self, user_data=None):
"ImageId": self.config['target_ami'],
"InstanceType": self.instance_type,
"EbsOptimized": False,
"IamInstanceProfile": {'Name': self.config['iam_role']},
"IamInstanceProfile": {'Name': self.config['instance_role']},
"Monitoring": {'Enabled': False},
'KeyName': self.config['ssh_key_name']
}
Expand Down
6 changes: 5 additions & 1 deletion lithops/standalone/backends/aws_ec2/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
}

REQ_PARAMS_1 = ('instance_id',)
REQ_PARAMS_2 = ('iam_role',)
REQ_PARAMS_2 = ('instance_role',)


def load_config(config_data):
Expand Down Expand Up @@ -66,6 +66,10 @@ def load_config(config_data):
else:
params_to_check = REQ_PARAMS_2

# iam_role is deprectaded. To be removed in a future release
if 'iam_role' in config_data['aws_ec2']:
config_data['aws_ec2']['instance_role'] = config_data['aws_ec2'].pop('iam_role')

for param in params_to_check:
if param not in config_data['aws_ec2']:
msg = f"'{param}' is mandatory in the 'aws_ec2' section of the configuration"
Expand Down

0 comments on commit b99eb23

Please sign in to comment.