Skip to content
This repository has been archived by the owner on Sep 1, 2024. It is now read-only.

Commit

Permalink
Add
Browse files Browse the repository at this point in the history
  • Loading branch information
cuong0993 committed Jul 13, 2023
0 parents commit a00ff90
Show file tree
Hide file tree
Showing 21 changed files with 667 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = false
max_line_length = 120
tab_width = 4

[*.dart]
max_line_length = 80

[{*.bash,*.sh,*.zsh}]
indent_size = 2
tab_width = 2

[{*.har,*.json}]
indent_size = 2

[{*.hcl,*.nomad}]
indent_size = 2

[{*.tf,*.tfvars}]
indent_size = 2

[{*.yaml,*.yml}]
indent_size = 2
6 changes: 6 additions & 0 deletions .github/set_secrets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

set -e

cd ..
gh secret set PRIVATE_KEY_PEM <private_key.pem
25 changes: 25 additions & 0 deletions .github/workflows/provision.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Provision
on:
push:
branches:
- main
schedule:
- cron: 0 * * * *
jobs:
provision-a1-flex:
name: Provision VM.Standard.A1.Flex
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
- env:
PRIVATE_KEY_PEM: ${{ secrets.PRIVATE_KEY_PEM }}
name: Add config files
run: echo "$PRIVATE_KEY_PEM" > private_key.pem
- name: Terraform Init
run: terraform init -backend-config="address=https://objectstorage.ap-singapore-1.oraclecloud.com/p/FD58RMnOqCAS68pqhFepGHKVLUMWQanan99Cs0oj3AOMJmDS8ibClvKwRP3xyv--/n/axyyz3fsrayr/b/terraform-state/o/terraform.tfstate"
--upgrade -reconfigure
- name: Terraform Apply
run: terraform apply -auto-approve -input=false --var-file=a1-flex.tfvars
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.terraform
private_key.pem
75 changes: 75 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
repos:

- hooks:
- id: check-merge-conflict
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
- id: requirements-txt-fixer
- id: check-json
- id: check-yaml
- id: debug-statements
- id: check-symlinks
- id: end-of-file-fixer
- id: trailing-whitespace
repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0

- hooks:
- additional_dependencies:
- mdformat-toc
- mdformat-tables
args:
- --wrap=80
exclude: README_TF\.md
id: mdformat
repo: https://github.com/executablebooks/mdformat
rev: 0.7.16

- hooks:
- args:
- -c=.yamllint-config.yaml
id: yamllint
repo: https://github.com/adrienverge/yamllint.git
rev: v1.28.0

- hooks:
- id: terraform_fmt
- id: terraform_validate
- args:
- --args=--config=__GIT_WORKING_DIR__/.tflint.hcl
id: terraform_tflint
repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.77.0

- hooks:
- entry: bash -c 'find . -name "*.yaml" -exec python3 -m pyaml -r {} \;; find
. -name "*.yml" -exec python3 -m pyaml -r {} \;'
id: yaml_format
language: system
name: Run yaml format
repo: local

- hooks:
- args:
- --baseline
- .secrets.baseline
id: detect-secrets
repo: https://github.com/Yelp/detect-secrets
rev: v1.4.0

- hooks:
- args:
- --exclude=SC1090,SC1091,SC2154
files: \.sh$
id: shellcheck
repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.9.0.2

- hooks:
- args:
- -l
- -w
files: \.sh$
id: shfmt
repo: https://github.com/cisagov/pre-commit-shfmt
rev: v0.0.2
112 changes: 112 additions & 0 deletions .secrets.baseline
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{
"version": "1.4.0",
"plugins_used": [
{
"name": "ArtifactoryDetector"
},
{
"name": "AWSKeyDetector"
},
{
"name": "AzureStorageKeyDetector"
},
{
"name": "Base64HighEntropyString",
"limit": 4.5
},
{
"name": "BasicAuthDetector"
},
{
"name": "CloudantDetector"
},
{
"name": "DiscordBotTokenDetector"
},
{
"name": "GitHubTokenDetector"
},
{
"name": "HexHighEntropyString",
"limit": 3.0
},
{
"name": "IbmCloudIamDetector"
},
{
"name": "IbmCosHmacDetector"
},
{
"name": "JwtTokenDetector"
},
{
"name": "KeywordDetector",
"keyword_exclude": ""
},
{
"name": "MailchimpDetector"
},
{
"name": "NpmDetector"
},
{
"name": "PrivateKeyDetector"
},
{
"name": "SendGridDetector"
},
{
"name": "SlackDetector"
},
{
"name": "SoftlayerDetector"
},
{
"name": "SquareOAuthDetector"
},
{
"name": "StripeDetector"
},
{
"name": "TwilioKeyDetector"
}
],
"filters_used": [
{
"path": "detect_secrets.filters.allowlist.is_line_allowlisted"
},
{
"path": "detect_secrets.filters.common.is_ignored_due_to_verification_policies",
"min_level": 2
},
{
"path": "detect_secrets.filters.heuristic.is_indirect_reference"
},
{
"path": "detect_secrets.filters.heuristic.is_likely_id_string"
},
{
"path": "detect_secrets.filters.heuristic.is_lock_file"
},
{
"path": "detect_secrets.filters.heuristic.is_not_alphanumeric_string"
},
{
"path": "detect_secrets.filters.heuristic.is_potential_uuid"
},
{
"path": "detect_secrets.filters.heuristic.is_prefixed_with_dollar_sign"
},
{
"path": "detect_secrets.filters.heuristic.is_sequential_string"
},
{
"path": "detect_secrets.filters.heuristic.is_swagger_file"
},
{
"path": "detect_secrets.filters.heuristic.is_templated_secret"
}
],
"results": {},
"generated_at": "2023-03-31T05:29:33Z"
}
25 changes: 25 additions & 0 deletions .terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .tflint.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
plugin "terraform" {
source = "github.com/terraform-linters/tflint-ruleset-terraform"
version = "0.2.1"
enabled = true
preset = "all"
}

rule "terraform_documented_variables" {
enabled = false
}

rule "terraform_documented_outputs" {
enabled = false
}
4 changes: 4 additions & 0 deletions .yamllint-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
extends: default
rules:
document-start: disable
line-length: disable
62 changes: 62 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
- [Create store bucket file](https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/terraformUsingObjectStore.htm)

- [Get OCIDs](https://docs.oracle.com/en-us/iaas/Content/API/Concepts/apisigningkey.htm#Required_Keys_and_OCIDs)

- [Create Pre-Authenticated Requests of the file](https://docs.oracle.com/en-us/iaas/Content/Object/Tasks/usingpreauthenticatedrequests.htm)

```shell
ssh-keygen -t rsa
```

```shell
ssh opc@public_ip -i ~/.ssh/id_rsa
```

```shell
terraform init
-backend-config="address=https://objectstorage.ap-singapore-1.oraclecloud.com/p/FD58RMnOqCAS68pqhFepGHKVLUMWQanan99Cs0oj3AOMJmDS8ibClvKwRP3xyv--/n/axyyz3fsrayr/b/terraform-state/o/terraform.tfstate"
--upgrade -reconfigure

terraform apply -auto-approve -input=false --var-file=a1-flex.tfvars
```

```shell
terraform init
-backend-config="address=https://objectstorage.ap-singapore-1.oraclecloud.com/p/1y_GJB5Qvwzz8xx8Y9SHK8cHGbqsOHwjwvbYvrcjsto1IGN3X1Y_Wzh-j7bcWkI9/n/axyyz3fsrayr/b/terraform-state/o/terraform.tfstate1"
-reconfigure

terraform apply -input=false --var-file=e2-micro.tfvars
```

# Install MySQL

```shell
yes | sudo yum update
sudo systemctl reboot
sudo dnf install @mysql:8.0 -y
```

# Start MySQL

```shell
sudo systemctl enable --now mysqld
systemctl status mysqld
sudo mysql_secure_installation
```

# Create MySQL user

```shell
mysql -uroot -p
CREATE USER 'user'@'%' IDENTIFIED BY 'P@ssw0rd';
GRANT ALL PRIVILEGES ON _._ TO 'user'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
```

# Disable firewall

```shell
sudo firewall-cmd --state
sudo systemctl stop firewalld
sudo systemctl disable firewalld
```
6 changes: 6 additions & 0 deletions a1-flex.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
compartment_name = "A1FlexCompartment"
compartment_description = "A1 Flex Compartment"
memory_in_gbs = "12"
ocpus = "2"
instance_shape = "VM.Standard.A1.Flex"
source_id = "ocid1.image.oc1.ap-singapore-1.aaaaaaaa2xvps6zmlfxqfi5ql5zwinjlsynda4z3wkwl554t2is2cg6ssx3a" // https://docs.oracle.com/en-us/iaas/images/image/7b142135-807b-4afa-afb2-d29acea83f27/
5 changes: 5 additions & 0 deletions compartment.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resource "oci_identity_compartment" "compartment" {
compartment_id = var.parent_compartment_id
description = var.compartment_description
name = var.compartment_name
}
Loading

0 comments on commit a00ff90

Please sign in to comment.