Skip to content

Commit 2b814a1

Browse files
committed
feat: initialize work on issue #55
1 parent bad0668 commit 2b814a1

File tree

13 files changed

+361
-19
lines changed

13 files changed

+361
-19
lines changed

CHANGELOG.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ Given a version number MAJOR.MINOR.PATCH:
2525
* Add support for freeform and defined tags for instances, vnics and block volumes (Fix #10, #11, #12, #13, #18, #20)
2626
* Add "module watermark" freeform tags: module defined and user defined freeform tags are merged on the final resource
2727
* Add support to provide the `ssh_authorized_keys` argument as a string or as a file (Fix #67 #70)
28+
* Provision instances with reserved Public IP
29+
* [ ] Define a backup policy for boot volume and additional block volumes
30+
* Add new outputs for each provisioned resources: "all_attributes" outputs have full provider coverage and are auto-updating.
2831

2932
=== Documentation
3033

@@ -47,7 +50,6 @@ Given a version number MAJOR.MINOR.PATCH:
4750
* Outputs produces unnecessarily multidimensional objects (Issue #31)
4851
* Repo maintenance:
4952
** add .gitattributes for consistent line ending and tab
50-
** add pre-commit configuration file
5153

5254
== 2.0.4 - 2021-02-13
5355

README.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Oracle Cloud Infrastructure Terraform Module for Compute Instance
22

3-
This Module provides an easy way to launch compute instances with advanced settings and good practices embedded.
3+
This module provides an easy way to launch compute instances with advanced settings and good practices embedded.
44

55
On top of the compute instance capabilities, this module can also provision and attach additional Block Volumes to the instances.
66

@@ -10,24 +10,20 @@ On top of the compute instance capabilities, this module can also provision and
1010
>
1111
> Oracle recommends that you do not use custom images without these rules unless you understand the security risks. See [Compute Best Practices](https://docs.cloud.oracle.com/iaas/Content/Compute/References/bestpracticescompute.htm#two) for recommendations on how to manage instances.
1212
13-
## Maintainers
14-
15-
This module is maintained by Oracle.
16-
1713
## Requirements
1814

1915
The diagram below summarizes the required components and their respective versions to use this module.
2016

2117
![versions](https://github.com/oracle-terraform-modules/terraform-oci-compute-instance/blob/main/docs/diagrams/versions.svg?raw=true&sanitize=true)
2218

23-
To enforce versions compatibility of both Terraform and the OCI provider, your root configuration should ideally include this block in `main.tf` for version pinning:
19+
To enforce versions compatibility of both Terraform and the OCI provider, your root configuration should ideally include this block for version pinning:
2420

2521
```HCL
2622
terraform {
27-
required_version = ">= 0.12"
23+
required_version = ">= 0.12.6"
2824
required_providers {
2925
oci = {
30-
version = ">= 3.27"
26+
version = ">= 4.0.0"
3127
}
3228
}
3329
}
@@ -59,11 +55,11 @@ module "instance" {
5955

6056
## What's coming next for this module?
6157

62-
The current focus is to get back in close the gap between this module and the provider's capabilities. We started with a complete code base update for [HCL2 syntax compatibility](https://github.com/oracle-terraform-modules/terraform-oci-compute-instance/releases/tag/v2.0.2), then adding support for [Regional Subnets](https://github.com/oracle-terraform-modules/terraform-oci-compute-instance/releases/tag/v2.0.4) and now [Flexible Shapes](https://github.com/oracle-terraform-modules/terraform-oci-compute-instance/pull/49).
58+
The current focus is to close the gap between this module and the provider's capabilities. We started with a complete codebase update for [HCL2 syntax compatibility](https://github.com/oracle-terraform-modules/terraform-oci-compute-instance/releases/tag/v2.0.2), then adding support for [Regional Subnets](https://github.com/oracle-terraform-modules/terraform-oci-compute-instance/releases/tag/v2.0.4) and lastly [Flexible Shapes](https://github.com/oracle-terraform-modules/terraform-oci-compute-instance/pull/49).
6359

6460
We will continue to push in that direction with the goal of [feature parity with the provider's capabilities](https://github.com/oracle-terraform-modules/terraform-oci-compute-instance/projects/4), as well as adding more features and integration points with other OCI services: Block Volume Backups, Secondary VNICs and IPs, etc ...
6561

66-
Compute Instances are also a perfect place to illustrate [module composition principles](https://www.terraform.io/docs/language/modules/develop/composition.html) reusing the other existing official Terraform OCI Modules
62+
Given the dependency to Network and Storage for Compute Instances,it is a perfect place to illustrate [module composition principles](https://www.terraform.io/docs/language/modules/develop/composition.html) and how to reuse the other official Terraform OCI modules.
6763

6864
## Configuring iSCSI volume attachments
6965

@@ -73,7 +69,8 @@ Compute Instances are also a perfect place to illustrate [module composition pri
7369

7470
## Contributing
7571

76-
This project is open source. Oracle appreciates any contributions that are made by the open source community: raising issues, improving documentation, fixing bugs, or adding new features.
72+
This project is open source and maintained by Oracle.
73+
Oracle appreciates any contributions that are made by the open source community: raising issues, improving documentation, fixing bugs, or adding new features.
7774

7875
Learn how to [contribute](https://github.com/oracle-terraform-modules/terraform-oci-compute-instance/blob/main/CONTRIBUTING.adoc).
7976

examples/instances_fixed_shape/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ You will need to collect the following information before you start:
1313

1414
1. your OCI provider authentication values
1515
2. a compartment OCID in which the instances will be created
16-
3. a subnet OCID to which the instance's primary VNICs will be attached
16+
3. a source OCID to deploy the instance, usually an image ocid from [OCI Platform Images list]
17+
4. a subnet OCID to which the instance's primary VNICs will be attached
1718

1819
For detailed instructions, see [docs/prerequisites.adoc]
1920

@@ -33,3 +34,5 @@ Then apply the example using the following commands:
3334

3435
[Terraform Variable Definition file]:https://www.terraform.io/docs/language/values/variables.html#variable-definitions-tfvars-files
3536
[docs/prerequisites.adoc]:https://github.com/oracle-terraform-modules/terraform-oci-compute-instance/blob/main/docs/prerequisites.adoc
37+
[Provisioning Infrastructure with Terraform]:https://www.terraform.io/docs/cli/run/index.html
38+
[OCI Platform Images list]:https://docs.oracle.com/en-us/iaas/images/

examples/instances_fixed_shape/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// Copyright (c) 2018, 2021 Oracle and/or its affiliates.
22

33
terraform {
4-
required_version = ">= 0.12" // terraform version below 0.12 is not tested/supported with this module
4+
required_version = ">= 0.13" // terraform version below 0.12 is not tested/supported with this module
55
required_providers {
66
oci = {
7-
version = ">= 3.27" // force downloading oci-provider compatible with terraform v0.12
7+
version = ">= 4.0.0" // force downloading oci-provider compatible with terraform v0.12
88
}
99
}
1010
}

examples/instances_flex_shape/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ You will need to collect the following information before you start:
1313

1414
1. your OCI provider authentication values
1515
2. a compartment OCID in which the instances will be created
16-
3. a subnet OCID to which the instance's primary VNICs will be attached
16+
3. a source OCID to deploy the instance, usually an image ocid from [OCI Platform Images list]
17+
4. a subnet OCID to which the instance's primary VNICs will be attached
1718

1819
For detailed instructions, see [docs/prerequisites.adoc]
1920

@@ -33,3 +34,5 @@ Then apply the example using the following commands:
3334

3435
[Terraform Variable Definition file]:https://www.terraform.io/docs/language/values/variables.html#variable-definitions-tfvars-files
3536
[docs/prerequisites.adoc]:https://github.com/oracle-terraform-modules/terraform-oci-compute-instance/blob/main/docs/prerequisites.adoc
37+
[Provisioning Infrastructure with Terraform]:https://www.terraform.io/docs/cli/run/index.html
38+
[OCI Platform Images list]:https://docs.oracle.com/en-us/iaas/images/

examples/instances_flex_shape/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// Copyright (c) 2018, 2021 Oracle and/or its affiliates.
22

33
terraform {
4-
required_version = ">= 0.12" // terraform version below 0.12 is not tested/supported with this module
4+
required_version = ">= 0.13" // terraform version below 0.12 is not tested/supported with this module
55
required_providers {
66
oci = {
7-
version = ">= 3.27" // force downloading oci-provider compatible with terraform v0.12
7+
version = ">= 4.0.0" // force downloading oci-provider compatible with terraform v0.12
88
}
99
}
1010
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Creating Compute Instances using Flex shape
2+
3+
This example illustrates how to use this module to creates compute instances with a reserved public IP.
4+
5+
One modules will be configured:
6+
7+
- 1 instance (1 OCPU, 1GB RAM) with a reserved public IP attached the primary VNIC.
8+
9+
## Prerequisites
10+
11+
You will need to collect the following information before you start:
12+
13+
1. your OCI provider authentication values
14+
2. a compartment OCID in which the instances will be created
15+
3. a source OCID to deploy the instance, usually an image ocid from [OCI Platform Images list]
16+
4. a subnet OCID to which the instance's primary VNICs will be attached
17+
18+
For detailed instructions, see [docs/prerequisites.adoc]
19+
20+
## Using this example with Terraform cli
21+
22+
Prepare one [Terraform Variable Definition file] named `terraform.tfvars` with the required authentication information.
23+
24+
*TIP: You can rename and configure `terraform.tfvars.example` from this example's folder.*
25+
26+
Then apply the example using the following commands:
27+
28+
```shell
29+
> terraform init
30+
> terraform plan
31+
> terraform apply
32+
```
33+
34+
See [Provisioning Infrastructure with Terraform] for more details about Terraform CLI and the available subcommands.
35+
36+
[Terraform Variable Definition file]:https://www.terraform.io/docs/language/values/variables.html#variable-definitions-tfvars-files
37+
[docs/prerequisites.adoc]:https://github.com/oracle-terraform-modules/terraform-oci-compute-instance/blob/main/docs/prerequisites.adoc
38+
[Provisioning Infrastructure with Terraform]:https://www.terraform.io/docs/cli/run/index.html
39+
[OCI Platform Images list]:https://docs.oracle.com/en-us/iaas/images/
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Copyright (c) 2018, 2021 Oracle and/or its affiliates.
2+
3+
terraform {
4+
required_version = ">= 0.13" // terraform version below 0.12 is not tested/supported with this module
5+
required_providers {
6+
oci = {
7+
version = ">= 4.0.0" // force downloading oci-provider compatible with terraform v0.12
8+
}
9+
}
10+
}
11+
12+
provider "oci" {
13+
tenancy_ocid = var.tenancy_ocid
14+
user_ocid = var.user_ocid
15+
fingerprint = var.fingerprint
16+
private_key_path = var.private_key_path
17+
region = var.region
18+
}
19+
20+
# # * This module will create 1 Flex Compute Instances, with a reserved public IP
21+
module "instance_reserved_ip" {
22+
source = "../../"
23+
# source = "oracle-terraform-modules/compute-instance/oci"
24+
# general oci parameters
25+
compartment_ocid = var.compartment_ocid
26+
freeform_tags = var.freeform_tags
27+
defined_tags = var.defined_tags
28+
# compute instance parameters
29+
ad_number = null
30+
instance_count = 1
31+
instance_display_name = "instance_reserved_ip"
32+
shape = var.shape
33+
source_ocid = var.source_ocid
34+
source_type = var.source_type
35+
instance_flex_memory_in_gbs = 1 # only used if shape is Flex type
36+
instance_flex_ocpus = 1 # only used if shape is Flex type
37+
# operating system parameters
38+
ssh_authorized_keys = var.ssh_authorized_keys
39+
# networking parameters
40+
assign_public_ip = var.assign_public_ip
41+
public_ip = var.public_ip
42+
subnet_ocids = var.subnet_ocids
43+
# storage parameters
44+
block_storage_sizes_in_gbs = [] # no block volume will be created
45+
preserve_boot_volume = false
46+
}
47+
48+
output "instance_reserved_ip" {
49+
description = "ocid of created instances."
50+
value = module.instance_reserved_ip.instances_summary
51+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Copyright (c) 2019, 2020 Oracle Corporation and/or affiliates. All rights reserved.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl
3+
4+
/*----------------------------------------------------------------------------
5+
HOW TO USE THIS FILE
6+
7+
1. keep this file in the same folder as your terraform *.tf files
8+
2. If your terraform config is managed with Git, add the tfvars file to your .gitignore.
9+
3. Keep your RSA private key outside of your terraform work folder!
10+
----------------------------------------------------------------------------*/
11+
12+
# provider identity parameters
13+
14+
tenancy_ocid = "<tenancy OCID>"
15+
user_ocid = "<user OCID>"
16+
fingerprint = "<PEM key fingerprint>"
17+
region = "<region in which to operate, example: us-ashburn-1, eu-frankfurt-1>"
18+
private_key_path = "<path to the private key that matches the fingerprint above>"
19+
20+
# general oci parameters
21+
22+
compartment_ocid = "<compartment OCID>"
23+
24+
# compute instance parameters
25+
26+
source_ocid = "<The OCID of an image or a boot volume>"
27+
28+
# operating system parameters
29+
30+
ssh_authorized_keys = "<path to the instance's public key>"
31+
32+
# networking parameters
33+
34+
subnet_ocids = ["<a list of the subnet OCIDs which to create the VNICs in>"]

0 commit comments

Comments
 (0)