-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
86f8432
commit 733cee9
Showing
10 changed files
with
115 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,40 @@ | ||
# Get Buckets | ||
Get-S3Bucket | ||
|
||
|
||
|
||
# New Bucket | ||
New-S3Bucket -BucketName chradavi-s3-imagebucket-test -Verbose | ||
$bucketName = "chradavi-s3-imagebucket-test" | ||
New-S3Bucket -BucketName $bucketName -Verbose | ||
|
||
# Check Encryption | ||
Get-S3Bucket -BucketName $bucketName | | ||
Get-S3BucketEncryption | ||
|
||
# Setup Encryption | ||
$Encryptionconfig = @{ | ||
ServerSideEncryptionByDefault = | ||
@{ServerSideEncryptionAlgorithm = "AES256" | ||
}} | ||
|
||
Set-S3BucketEncryption -BucketName $bucketName -ServerSideEncryptionConfiguration_ServerSideEncryptionRule $Encryptionconfig | ||
|
||
|
||
Get-S3Bucket -BucketName $bucketName | | ||
Get-S3BucketEncryption | ||
|
||
|
||
# Delete All Objects in a bucket | ||
Get-S3Object -BucketName chradavi-s3-imagebucket-test | | ||
Get-S3Object -BucketName $bucketName | | ||
Remove-S3Object -Verbose -Force | ||
|
||
# Upload Objects to a bucket | ||
Get-Item -Path .\Pics\* | | ||
Get-Item -Path C:\github\PowerShellAndAWS\Pics\* | | ||
ForEach-Object { | ||
$key = [io.path]::Combine("input",$PSItem.Name) | ||
Write-S3Object -BucketName chradavi-s3-imagebucket-test -File $PSItem.FullName -Verbose -Key $key | ||
Write-S3Object -BucketName $bucketName -File $PSItem.FullName -Verbose -Key $key | ||
} | ||
|
||
|
||
# Delete a bucket | ||
Get-S3Bucket $bucketName | | ||
Remove-S3Bucket -Verbose -Force |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# CDK Intro | ||
|
||
# Cloning a new Repo | ||
|
||
git clone https://git-codecommit.us-west-2.amazonaws.com/v1/repos/PowerShell-Repository | ||
|
||
# Generating the lambda package | ||
|
||
Set-Location -Path C:\github\PowerShell-Repository | ||
|
||
New-AWSPowerShellLambda -Template basic -Verbose | ||
Copy-Item -Path C:\github\PowerShellAndAws\LambdaTemplateExample\buildspec.yaml -Destination . -Verbose | ||
Code C:\github\PowerShell-Repository | ||
|
||
# Check In Our Code, Review the pipeline | ||
|
||
|
||
# Invoke Our Function | ||
Invoke-LMFunction -FunctionName 'PowerShellCICD-Sample' -LogType Tail | ||
Get-CWLLastLogEvent -LogGroupNamePrefix '/aws/lambda/PowerShellCICD-Sample' | ||
|
||
|
||
## Make a change and watch the build | ||
|
||
While($true) | ||
{ | ||
Start-Sleep -Seconds 5 | ||
Invoke-LMFunction -FunctionName 'PowerShellCICD-Sample' -LogType Tail -Verbose | ||
Get-CWLLastLogEvent -LogGroupNamePrefix '/aws/lambda/PowerShellCICD-Sample' | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# PowerShell script file to be executed as a AWS Lambda function. | ||
# | ||
# When executing in Lambda the following variables will be predefined. | ||
# $LambdaInput - A PSObject that contains the Lambda function input data. | ||
# $LambdaContext - An Amazon.Lambda.Core.ILambdaContext object that contains information about the currently running Lambda environment. | ||
# | ||
# The last item in the PowerShell pipeline will be returned as the result of the Lambda function. | ||
# | ||
# To include PowerShell modules with your Lambda function, like the AWS.Tools.S3 module, add a "#Requires" statement | ||
# indicating the module and version. If using an AWS.Tools.* module the AWS.Tools.Common module is also required. | ||
|
||
#Requires -Modules @{ModuleName='AWS.Tools.Common';ModuleVersion='4.1.14.0'} | ||
|
||
# Uncomment to send the input event to CloudWatch Logs | ||
Write-Host (ConvertTo-Json -InputObject $LambdaInput -Compress -Depth 5) | ||
Write-Host "Hello World" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# PowerShell script file to be executed as a AWS Lambda function. | ||
# | ||
# When executing in Lambda the following variables will be predefined. | ||
# $LambdaInput - A PSObject that contains the Lambda function input data. | ||
# $LambdaContext - An Amazon.Lambda.Core.ILambdaContext object that contains information about the currently running Lambda environment. | ||
# | ||
# The last item in the PowerShell pipeline will be returned as the result of the Lambda function. | ||
# | ||
# To include PowerShell modules with your Lambda function, like the AWS.Tools.S3 module, add a "#Requires" statement | ||
# indicating the module and version. If using an AWS.Tools.* module the AWS.Tools.Common module is also required. | ||
|
||
#Requires -Modules @{ModuleName='AWS.Tools.Common';ModuleVersion='4.1.14.0'} | ||
|
||
# Uncomment to send the input event to CloudWatch Logs | ||
# Write-Host (ConvertTo-Json -InputObject $LambdaInput -Compress -Depth 5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
version: 0.2 | ||
|
||
phases: | ||
install: | ||
commands: | ||
- pwsh -command Install-Module -Name AWSLambdaPSCore -Verbose -Force | ||
build: | ||
commands: | ||
- pwsh -command Publish-AWSPowerShellLambda -ScriptPath ./basic/basic.ps1 -Name 'PowerShellCICD-Sample' -IAMRoleArn arn:aws:iam::124535484568:role/PowerShell-Lambda-ExecutionRole -Verbose |