Skip to content

Instantly share code, notes, and snippets.

View stknohg's full-sized avatar

Takuya Shibata stknohg

View GitHub Profile
@stknohg
stknohg / Remove-Default-AWSPowerShell.NetCore-on-CloudShell.ps1
Created March 17, 2022 13:05
AWS CloudShellのPowerShellにデフォルトでインストールされる AWSPowerShell.NetCore モジュールを削除するコマンド
# 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コマンドと同等の値を返す)
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
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 June 25, 2024 03:55
Windows Server 2022にWindows Terminal, WinGetをインストールする関数
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)を作るサンプル
data "aws_caller_identity" "current" {}
// System name settings
variable "sysname" {
type = string
default = "mysgw"
}
variable "envname" {
type = string
default = "dev"
@stknohg
stknohg / PowerShellMemoOnWin11-21H2.md
Last active June 29, 2021 08:59
[WIP] Windows 11のWindows PowerShell周りのメモ

注意事項

このGistの内容は随時更新します。

  • 2021/6/29 時点 : Windows 11 Pro 21H2 (Build 22000.51)
    • Insider preview から更新

バージョン情報

@stknohg
stknohg / PowerShellMemoOnWin10-21H1.md
Created May 19, 2021 03:22
Windows 10 May 2021 Update (21H1)で変更されたPowerShellモジュールについてのメモ

バージョン情報

PS C:\> $PSVersionTable | sort Name

Name                           Value
----                           -----
PSVersion                      5.1.19041.906
PSEdition                      Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
@stknohg
stknohg / Dockerfile
Last active September 13, 2021 10:07
CloudFormation Rainをお手軽に実行するDockerコンテナイメージ
#
# CloudFormation Rain Docker image
#
# How to build:
# docker build -t aws-cfn-rain .
# How to use (e.g. docker run from PowerShell host):
# docker run --rm -it -v "$HOME/.aws/:/root/.aws" -v "$($pwd.Path):/aws" -e AWS_PROFILE aws-cfn-rain --version
# docker run --rm -it -v "$HOME/.aws/:/root/.aws" -v "$($pwd.Path):/aws" -e AWS_PROFILE aws-cfn-rain deploy ./sample.yaml
#
FROM amazon/aws-cli:latest
@stknohg
stknohg / Set-AWSCredentialWithRegion.ps1
Created January 8, 2021 11:15
Set-AWSCredentialと同時にプロファイルに設定されているリージョンをデフォルト設定する関数
function Set-AWSCredentialWithRegion {
[CmdletBinding()]
param (
[string]$ProfileName
)
# Invoke Set-AWSCredential first
Write-Verbose "Invoke Set-AWSCredential -ProfileName $ProfileName "
Set-AWSCredential -ProfileName $ProfileName -Scope Global
if (-not $StoredAWSCredentials) {
@stknohg
stknohg / PowerShellMemoOnWin10-20H2.md
Created November 24, 2020 06:12
Windows 10 October 2020 Update(20H2)で変更されたPowerShellモジュールについてのメモ

バージョン情報

PS C:\> $PSVersionTable | sort Name

Name                           Value
----                           -----
PSVersion                      5.1.19041.1
PSEdition                      Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}