Skip to content

Commit

Permalink
#6
Browse files Browse the repository at this point in the history
  • Loading branch information
tanakaryo committed Jun 20, 2024
1 parent 5d54726 commit 556a981
Show file tree
Hide file tree
Showing 11 changed files with 131 additions and 0 deletions.
Binary file added infrastructure-as-code/.DS_Store
Binary file not shown.
Binary file added infrastructure-as-code/terraform/.DS_Store
Binary file not shown.
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions infrastructure-as-code/terraform/apps/app1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Application Architecture
### this application constructed with one azure vm.
![Architecture](./azure_arche1.drawio.png)
19 changes: 19 additions & 0 deletions infrastructure-as-code/terraform/apps/app1/azure_arche1.drawio
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<mxfile host="app.diagrams.net" modified="2024-06-20T06:34:44.755Z" agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36" etag="5Pr_Yqwf_4-33gMRPsJe" version="24.5.5" type="device">
<diagram name="ページ1" id="SW2eRD1bX3vJ8InefSC3">
<mxGraphModel dx="1350" dy="713" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="bGpbJ8u76edb3KDOJavG-2" value="Private subnet" style="points=[[0,0],[0.25,0],[0.5,0],[0.75,0],[1,0],[1,0.25],[1,0.5],[1,0.75],[1,1],[0.75,1],[0.5,1],[0.25,1],[0,1],[0,0.75],[0,0.5],[0,0.25]];outlineConnect=0;gradientColor=none;html=1;whiteSpace=wrap;fontSize=12;fontStyle=0;container=1;pointerEvents=0;collapsible=0;recursiveResize=0;shape=mxgraph.aws4.group;grIcon=mxgraph.aws4.group_security_group;grStroke=0;strokeColor=#00A4A6;fillColor=#E6F6F7;verticalAlign=top;align=left;spacingLeft=30;fontColor=#147EBA;dashed=0;" vertex="1" parent="1">
<mxGeometry x="200" y="250" width="310" height="260" as="geometry" />
</mxCell>
<mxCell id="bGpbJ8u76edb3KDOJavG-1" value="VPC" style="shape=mxgraph.ibm.box;prType=vpc;fontStyle=0;verticalAlign=top;align=left;spacingLeft=32;spacingTop=4;fillColor=none;rounded=0;whiteSpace=wrap;html=1;strokeColor=#4376BB;strokeWidth=2;dashed=0;container=1;spacing=-4;collapsible=0;expand=0;recursiveResize=0;" vertex="1" parent="1">
<mxGeometry x="140" y="190" width="430" height="370" as="geometry" />
</mxCell>
<mxCell id="bGpbJ8u76edb3KDOJavG-3" value="" style="verticalLabelPosition=bottom;html=1;verticalAlign=top;align=center;strokeColor=none;fillColor=#00BEF2;shape=mxgraph.azure.virtual_machine;" vertex="1" parent="bGpbJ8u76edb3KDOJavG-1">
<mxGeometry x="154" y="140" width="120" height="100" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
resource "azurerm_virtual_network" "example_network" {
name = "example-network"
address_space = [ "10.0.0.0/16" ]
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
}

resource "azurerm_subnet" "example_subnet" {
name = "example-subnet"
resource_group_name = azurerm_resource_group.example.name
virtual_network_name = azurerm_virtual_network.example_network.name
address_prefixes = [ "10.0.2.0/24" ]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "3.108.0"
}
azapi = {
source = "azure/azapi"
version = "1.13.1"
}
}
}

provider "azurerm" {
skip_provider_registration = true
features {
resource_group {
prevent_deletion_if_contains_resources = false
}
}

subscription_id = var.ARM_SUBSCRIPTION_ID
tenant_id = var.ARM_TENANT_ID
client_id = var.ARM_CLIENT_ID
client_secret = var.ARM_CLIENT_SECRET
}

provider "azapi" {
}

resource "azurerm_resource_group" "example" {
name = "example-resource"
location = "Japan East"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
variable "ARM_SUBSCRIPTION_ID" {
type = string
}

variable "ARM_CLIENT_SECRET" {
type = string
}

variable "ARM_TENANT_ID" {
type = string
}

variable "ARM_CLIENT_ID" {
type = string
}
47 changes: 47 additions & 0 deletions infrastructure-as-code/terraform/apps/app1/create-azure-vm/vm.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
resource "azurerm_network_interface" "example_interface" {
name = "example-interface"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name

ip_configuration {
name = "configuration1"
subnet_id = azurerm_subnet.example_subnet.id
private_ip_address_allocation = "Dynamic"
}
}

resource "azurerm_virtual_machine" "example_vm" {
name = "example-vm"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
network_interface_ids = [azurerm_network_interface.example_interface.id]
vm_size = "Standard_DS1_v2"

storage_image_reference {
publisher = "Canonical"
offer = "UbuntuServer"
sku = "16.04-LTS"
version = "latest"
}

storage_os_disk {
name = "myosdisk1"
caching = "ReadWrite"
create_option = "FromImage"
managed_disk_type = "Standard_LRS"
}

os_profile {
computer_name = "hostname"
admin_username = "testadmin"
admin_password = "Password1234!"
}

os_profile_linux_config {
disable_password_authentication = false
}

tags = {
environment = "stg"
}
}

0 comments on commit 556a981

Please sign in to comment.