Skip to content

Commit

Permalink
Merge pull request #3 from emma-community/tickets/EMMA-4499
Browse files Browse the repository at this point in the history
Revert "EMMA-4499 Delete unreleased code"
  • Loading branch information
DenisTyunin authored Jun 24, 2024
2 parents 926f56c + 2b8aac2 commit e5e1173
Show file tree
Hide file tree
Showing 25 changed files with 2,221 additions and 22 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ approach guarantees freedom to leverage the right cloud services you need.
## Features

- Provision and manage virtual machines.
- Utilize spot instances for cost-effective computing.
- Manage SSH keys for secure access to instances.
- Define and manage security groups to control network traffic.

## Installation

Expand All @@ -22,7 +25,7 @@ Then, run `terraform init`:
required_providers {
emma = {
source = "emma-community/emma"
version = "0.0.1-alpha"
version = "0.0.1"
}
}
}
Expand All @@ -46,7 +49,7 @@ of provisioning a virtual machine, you can find more documentation on the [terra
ram_gb = 1
volume_type = "ssd"
volume_gb = 8
ssh_key_id = 1
ssh_key_id = emma_ssh_key.ssh_key.id
}
```

Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ terraform {
required_providers {
emma = {
source = "emma-community/emma"
version = "0.0.1-alpha"
version = "0.0.1"
}
}
}
Expand Down
79 changes: 79 additions & 0 deletions docs/resources/security_group.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "emma_security_group Resource - emma"
subcategory: ""
description: |-
This resource creates a security group.
A security group refers to a set of rules that determine what network traffic is allowed to enter or leave a particular compute instance. It acts as a virtual firewall, controlling inbound and outbound traffic based on predefined rules.
Security groups operate based on predefined rules that allow traffic based on specified criteria, such as source IP address, destination IP address, port number, and protocol.
When creating a security group, provide its name and a set of inbound and outbound rules. You can only define rules that allow traffic, not deny it. All traffic is denied except for explicitly allowed traffic.
Security groups control TCP, SCTP, GRE, ESP, AH, UDP, and ICMP protocols, or all the selected protocols at once.
After creating a security group, a set of default rules is added to the security group. These rules are immutable, and you can't edit or delete them.
All traffic in the selected protocol is allowed if the IP range in a rule is set to 0.0.0.0/0.
---

# emma_security_group (Resource)

This resource creates a security group.

A security group refers to a set of rules that determine what network traffic is allowed to enter or leave a particular compute instance. It acts as a virtual firewall, controlling inbound and outbound traffic based on predefined rules.

Security groups operate based on predefined rules that allow traffic based on specified criteria, such as source IP address, destination IP address, port number, and protocol.

When creating a security group, provide its name and a set of inbound and outbound rules. You can only define rules that allow traffic, not deny it. All traffic is denied except for explicitly allowed traffic.

Security groups control TCP, SCTP, GRE, ESP, AH, UDP, and ICMP protocols, or all the selected protocols at once.

After creating a security group, a set of default rules is added to the security group. These rules are immutable, and you can't edit or delete them.

All traffic in the selected protocol is allowed if the IP range in a rule is set to `0.0.0.0/0`.

## Example Usage

```terraform
resource "emma_security_group" "security_group" {
name = "Example"
rules = [
{
direction = "INBOUND"
protocol = "all"
ports = "8080"
ip_range = "8.8.8.8/32"
},
{
direction = "INBOUND"
protocol = "all"
ports = "8080"
ip_range = "4.4.4.4/32"
}
]
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `name` (String) Security group name
- `rules` (Attributes List) List of the inbound and outbound rules in the Security group (see [below for nested schema](#nestedatt--rules))

### Optional

- `last_modification_error_description` (String) Text of the error when the Security group was last edited

### Read-Only

- `id` (String) ID of the security group
- `recomposing_status` (String) Recomposing status of the security group. When a new Virtual machine is added to the Security group it starts a synchronization process. During this process the Security group will have a Recomposing status.
- `synchronization_status` (String) Synchronization status of the security group. When you make changes in the rules the changes are propagated to the respective provider’s security groups. While this is happening the security groups have the status Synchronizing. After it is done the status changes to Synchronized. When another VM is added to the security group it will not be synchronized at first with the other VMs, therefore the status will be Desynchronized.

<a id="nestedatt--rules"></a>
### Nested Schema for `rules`

Required:

- `direction` (String) Direction of the network traffic, available values: INBOUND or OUTBOUND
- `ip_range` (String) Allowed IP or IP range, available values: ip (8.8.8.8), ip range (8.8.8.8\32), all ip addresses (0.0.0.0\0)
- `ports` (String) Allowed port or port range, available values: port number (8080), port range (1000-1005), all ports (all)
- `protocol` (String) Network protocol, available values: all, TCP, SCTP, GRE, ESP, AH, UDP or ICMP
122 changes: 122 additions & 0 deletions docs/resources/spot_instance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "emma_spot_instance Resource - emma"
subcategory: ""
description: |-
This resource creates a spot instance according to the specified parameters.
A Spot Instance is a specialized compute instance that allows you to access and utilize unused instance capacity at a steeply discounted rate. Spot price is charged on an hourly basis.
To create a spot instance, follow these steps:
Select a data center using the emma_data_center data source. The data center determines the provider and location of the spot instance.
Select an available hardware configuration for the spot instance.
Select or create an SSH key for the spot instance using the emma_ssh_key resource.
Select an operating system using the emma_operating_system data source.
Choose one of the cloud network types: multi-cloud, isolated or default. Choose the multi-cloud network type if you need to connect compute instances from different providers.
Select or create an security group for the spot instance using the emma_security_group resource. You may choose not to specify a security group. In this case, the spot instance will be added to the default security group.
A price field of a spot instance is not required.
The spot instance market operates on a bidding system. Your specified price acts as your bid in this market. If your bid is higher than the current spot price, your instance request will likely be fulfilled. However, if the market price exceeds your bid, your instance may not be launched or could be terminated if already running.
---

# emma_spot_instance (Resource)

This resource creates a spot instance according to the specified parameters.

A Spot Instance is a specialized compute instance that allows you to access and utilize unused instance capacity at a steeply discounted rate. Spot price is charged on an hourly basis.

To create a spot instance, follow these steps:

1. Select a data center using the `emma_data_center` data source. The data center determines the provider and location of the spot instance.

2. Select an available hardware configuration for the spot instance.

3. Select or create an SSH key for the spot instance using the `emma_ssh_key` resource.

4. Select an operating system using the `emma_operating_system` data source.

5. Choose one of the cloud network types: multi-cloud, isolated or default. Choose the multi-cloud network type if you need to connect compute instances from different providers.

6. Select or create an security group for the spot instance using the `emma_security_group` resource. You may choose not to specify a security group. In this case, the spot instance will be added to the default security group.

A `price` field of a spot instance is not required.

The spot instance market operates on a bidding system. Your specified price acts as your bid in this market. If your bid is higher than the current spot price, your instance request will likely be fulfilled. However, if the market price exceeds your bid, your instance may not be launched or could be terminated if already running.

## Example Usage

```terraform
resource "emma_spot_instance" "spot_instance" {
name = "Example"
data_center_id = data.emma_data_center.aws_spot.id
os_id = data.emma_operating_system.ubuntu.id
cloud_network_type = "multi-cloud"
vcpu_type = "shared"
vcpu = 2
ram_gb = 1
volume_type = "ssd"
volume_gb = 8
security_group_id = emma_security_group.security_group.id
ssh_key_id = emma_ssh_key.ssh_key.id
price = 0.00305205479452
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `cloud_network_type` (String) Cloud network type, available values: multi-cloud, isolated or default, spot instance will be recreated after changing this value
- `data_center_id` (String) Data center ID of the spot instance, spot instance will be recreated after changing this value
- `name` (String) Name of the spot instance, spot instance will be recreated after changing this value
- `os_id` (Number) Operating system ID of the spot instance, spot instance will be recreated after changing this value
- `price` (Number) Offer price of the spot instance, spot instance will be recreated after changing this value
- `ram_gb` (Number) Capacity of the RAM in gigabytes, spot instance will be recreated after changing this value
- `ssh_key_id` (Number) Ssh key ID of the spot instance, spot instance will be recreated after changing this value
- `vcpu` (Number) Number of virtual Central Processing Units (vCPUs), spot instance will be recreated after changing this value
- `vcpu_type` (String) Type of virtual Central Processing Units (vCPUs), available values: shared, standard or hpc, spot instance will be recreated after changing this value
- `volume_gb` (Number) Volume size in gigabytes, spot instance will be recreated after changing this value
- `volume_type` (String) Volume type of the compute instance, available values: ssd or ssd-plus, spot instance will be recreated after changing this value

### Optional

- `security_group_id` (Number) Security group ID of the spot instance, the process of changing the security group will start after changing this value

### Read-Only

- `cost` (Attributes) (see [below for nested schema](#nestedatt--cost))
- `disks` (Attributes List) (see [below for nested schema](#nestedatt--disks))
- `id` (String) ID of the spot instance
- `networks` (Attributes List) (see [below for nested schema](#nestedatt--networks))
- `status` (String) Status of the spot instance

<a id="nestedatt--cost"></a>
### Nested Schema for `cost`

Read-Only:

- `currency` (String) Currency of cost
- `price` (Number) Cost of the spot instance for the period
- `unit` (String) Cost period


<a id="nestedatt--disks"></a>
### Nested Schema for `disks`

Read-Only:

- `id` (Number) Volume ID
- `is_bootable` (Boolean) Indicates whether the volume is bootable or not
- `size_gb` (Number) Volume size in gigabytes
- `type` (String) Volume type
- `type_id` (Number) ID of the volume type


<a id="nestedatt--networks"></a>
### Nested Schema for `networks`

Read-Only:

- `id` (Number) Network ID
- `ip` (String) Network IP
- `network_type` (String) Network type
- `network_type_id` (Number) ID of the network type
44 changes: 44 additions & 0 deletions docs/resources/ssh_key.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "emma_ssh_key Resource - emma"
subcategory: ""
description: |-
This method creates an SSH key that can be used for Linux compute instance creation. An SSH key can be created in two ways: generated by emma or imported by the user.
If you want to generate a key, specify two fields: name and key_type (RSA or ED25519). The key will be generated, and you will receive a private key in the response. The private key will be shown only once, so copy and save it to connect to the Linux compute instances.
If you want to import an existing SSH key, specify two fields: name and key. In the key field, insert your public SSH key as a string. It will be imported.
---

# emma_ssh_key (Resource)

This method creates an SSH key that can be used for Linux compute instance creation. An SSH key can be created in two ways: generated by emma or imported by the user.

If you want to **generate** a key, specify two fields: name and key_type (RSA or ED25519). The key will be generated, and you will receive a private key in the response. The private key will be shown only once, so copy and save it to connect to the Linux compute instances.

If you want to **import** an existing SSH key, specify two fields: name and key. In the key field, insert your public SSH key as a string. It will be imported.

## Example Usage

```terraform
resource "emma_ssh_key" "ssh_key" {
name = "Example"
key_type = "RSA"
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `name` (String) SSH key name

### Optional

- `key` (String) SSH public key, ssh key will be recreated after changing this value
- `key_type` (String) SSH key type, available values: RSA or ED25519, ssh key will be recreated after changing this value

### Read-Only

- `fingerprint` (String) SSH key fingerprint
- `id` (String) ID of the SSH key
- `private_key` (String) SSH private key
3 changes: 2 additions & 1 deletion docs/resources/vm.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ resource "emma_vm" "vm" {
ram_gb = 1
volume_type = "ssd"
volume_gb = 8
ssh_key_id = 1
security_group_id = emma_security_group.security_group.id
ssh_key_id = emma_ssh_key.ssh_key.id
}
```

Expand Down
Loading

0 comments on commit e5e1173

Please sign in to comment.