Skip to content

Instantly share code, notes, and snippets.

View stknohg's full-sized avatar

Takuya Shibata stknohg

View GitHub Profile
@stknohg
stknohg / windows-server-setup-japanese-ui.yaml
Last active April 9, 2023 00:29
EC2 Image BuilderでWindows Serverを日本語化するコンポーネント
View windows-server-setup-japanese-ui.yaml
name: windows-server-setup-japanese-ui
description: Install Japanese Language pack and Update UI configurations.
schemaVersion: 1.0
parameters:
- S3BucketName:
type: string
default: 'your-bucket-name'
description: Set your S3 bucket name.
- S3BucketPath:
@stknohg
stknohg / Install-PgCommandLineTools.ps1
Created March 14, 2023 05:14
Windows環境にPostgreSQLのコマンドラインツールをインストールするスクリプト
View Install-PgCommandLineTools.ps1
# Download Installer
$ProgressPreference = 'SilentlyContinue'
$installerUrl = 'https://get.enterprisedb.com/postgresql/postgresql-15.2-1-windows-x64.exe'
$installerLocalPath = Join-Path $env:TEMP 'postgresql-windows-x64.exe'
Invoke-WebRequest -Uri $installerUrl -OutFile $installerLocalPath
# Invoke Installer
$params = @{
FilePath = $installerLocalPath # InstallBuilder
ArgumentList = @('--mode unattended', '--unattendedmodeui none', '--disable-components server,pgAdmin,stackbuilder')
@stknohg
stknohg / install_powershell_on_arm_linux.sh
Created November 1, 2022 07:44
Arm版LinuxにPowerShell 7をインストールするスクリプト
View install_powershell_on_arm_linux.sh
#!/usr/bin/env bash
# Download Arm PowerShell tar.gz
ver_name=$(curl -s https://api.github.com/repos/PowerShell/PowerShell/releases/latest | grep tag_name | sed -e 's/^\s*"tag_name".*"v\(.*\)".*$/\1/')
curl -L -o /tmp/powershell.tar.gz "https://github.com/PowerShell/PowerShell/releases/download/v${ver_name}/powershell-${ver_name}-linux-arm64.tar.gz"
# Create the target folder and expand PowerShell
sudo mkdir -p /opt/microsoft/powershell/7
sudo tar zxf /tmp/powershell.tar.gz -C /opt/microsoft/powershell/7
# Set pwsh binary executable
@stknohg
stknohg / AzureVM_Nested_Virtualization.md
Created June 26, 2022 03:06
Azure VMで入れ子の仮想化をサポートしているシリーズ
View AzureVM_Nested_Virtualization.md

Azure VMで入れ子の仮想化をサポートしているシリーズ

元ネタは以下のDocs。

流石に全部を動作検証するのは無理。

一覧表

@stknohg
stknohg / 00-provider.tf
Last active May 21, 2022 04:08
S3サーバーアクセスログを試すTerraformサンプル
View 00-provider.tf
terraform {
required_version = "~> 1.2.0"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.15.1"
}
}
}
@stknohg
stknohg / Remove-Default-AWSPowerShell.NetCore-on-CloudShell.ps1
Created March 17, 2022 13:05
AWS CloudShellのPowerShellにデフォルトでインストールされる AWSPowerShell.NetCore モジュールを削除するコマンド
View Remove-Default-AWSPowerShell.NetCore-on-CloudShell.ps1
# CloudShell の $Profile に仕込む想定
if ($env:AWS_EXECUTION_ENV -eq 'CloudShell') {
$moduleBase = (Get-Module AWSPowerShell.NetCore -ListAvailable).ModuleBase
if ($null -ne $moduleBase) {
$modulePath = Split-Path -Parent $moduleBase
if (Test-Path $modulePath) { sudo rm -rf $modulePath }
}
}
@stknohg
stknohg / Get-StringHash.ps1
Last active January 31, 2022 03:02
文字列のハッシュ値を求める関数 (md5sum, sha1sum, sha256sum, sha384sum, sha512sumコマンドと同等の値を返す)
View Get-StringHash.ps1
function Get-StringHash {
[CmdletBinding()]
param (
[Parameter(ValueFromPipeline=$true)]
[string]$InputValue,
[ValidateSet('MD5', 'SHA1', 'SHA256', 'SHA384', 'SHA512')]
[string]$Algorithm = 'SHA256',
[switch]$ToUpperCase
)
begin {
@stknohg
stknohg / Dockerfile_AWS_CLI_v1
Created October 9, 2021 05:51
Dockerfile for AWS CLI v1
View Dockerfile_AWS_CLI_v1
FROM python:3.10.0-alpine
RUN pip3 install awscli --upgrade --no-cache-dir
ENTRYPOINT [ "/usr/local/bin/aws" ]
@stknohg
stknohg / Install-LatestWinGet.ps1
Last active October 23, 2023 13:24
Windows Server 2022にWindows Terminal, WinGetをインストールする関数
View Install-LatestWinGet.ps1
function Install-LatestWinGet ([switch]$SkipInstallVCLibs) {
# Install prerequisites
if (-not $SkipInstallVCLibs) {
$vcLibsUrl = 'https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx'
Write-Host -ForegroundColor Green "Download $vcLibsUrl"
Add-AppxPackage -Path $vcLibsUrl
}
# Find the latest assets url
$latest = Invoke-RestMethod -Uri 'https://api.github.com/repos/microsoft/winget-cli/releases/latest'
@stknohg
stknohg / main.tf
Last active September 18, 2021 03:43
TerraformでAWS Storage Gateway (S3 File Gateway)を作るサンプル
View main.tf
data "aws_caller_identity" "current" {}
// System name settings
variable "sysname" {
type = string
default = "mysgw"
}
variable "envname" {
type = string
default = "dev"