Skip to content

DomainGroupOSS/domainAwsDSCResources

Repository files navigation

DOMAINAWSDSCRESOURCES

DSC Resources for AWS EC2 Instances

Language Release Version Release Date Bartender Version
psbadge releasebadge datebadge btbadge

Authors: Adrian.Andersson

Company: Domain Group

Latest Release Notes: here



Getting Started

Installation

How to install:

install-module domainAwsDSCResources

Example

Local DSC create/Execute (Not push/pull)

Assumes directory and execution location is already done

Assumes your EC2 instances have sufficient permissions to self-tag

# Set the DSC Configuration 
configuration myEc2Configuration
{
    Param
    (
        [Parameter(Mandatory=$true)]
        [string]$timeZoneName,
        [Parameter(Mandatory=$true)]
        [string]$instanceId,
        [Parameter(Mandatory=$true)]
        [hashtable]$instanceTags
    )
    Import-DscResource -ModuleName domainAwsDSCResources

    Node 'localhost'
    {

        dmAwsTimeSync timeZone
        {
            Ensure = 'Present'
            timeZoneName = $timeZoneName
        }

        dmAwsTagInstance applyTags
        {
            Name = 'applyTags'
            Ensure = 'Present'
            InstanceId = $instanceId
            instanceTags = $instanceTags
        }

    }

}


#Set the tags with a hashtable
$tags = @{
    name = $($env:computername)
    environment = 'myEnvironment'

}

#Splat dsc hashtable
$dscSplat = @{
    instanceTags = $tags
    instanceId = $(Invoke-RestMethod http://169.254.169.254/latest/meta-data/instance-id).Trim() #Get the instanceId from the metadata uri
    timeZoneName = 'AUS Eastern Standard Time'
}

#Create DSC MOF
myEc2Configuration @dscSplat

#Execute DSC MOF
start-dscConfiguration myEc2Configuration -verbose -wait -force


#Get the date twice to ensure the computer actually changes timezones
#The first one seems to trigger the change, the second is to confirm the change
get-date
get-date

What Is It

Some AWS DSC Resources for managing AWS Windows EC2 Instances.

These are an open-source copy from our internal DSC resources

dmAwsTagInstance

Add tags to an EC2 instance

dmAwsTimeSync

Set the AWS TimeSync server as the NTP server

May need to run get-date to ensure timezone changes took effect


Acknowledgements


Build With Bartender

A PowerShell Module Framework

Releases

No releases published

Packages

No packages published