Skip to content

Instantly share code, notes, and snippets.

Matt Weagle mweagle

Block or report user

Report or block mweagle

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mweagle
mweagle / build.groovy
Created May 22, 2016
Jenkins 2.0 build
View build.groovy
node {
def golangExists = fileExists '/home/ec2-user/go'
if (!golangExists) {
stage "Configure Go"
sh('curl -vs -L https://storage.googleapis.com/golang/go1.6.2.linux-amd64.tar.gz -o /home/ec2-user/go.linux-amd64.tar.gz')
sh('tar -xzf /home/ec2-user/go.linux-amd64.tar.gz -C /home/ec2-user')
} else {
sh('echo Go installed')
}
@mweagle
mweagle / pipeline.yml
Created May 25, 2016
Concourse CI pipeline for http://gosparta.io application build
View pipeline.yml
################################################################################
# REFERENCES
# ConcourseCI Docs: https://concourse.ci
# Concourse tutorial: https://github.com/starkandwayne/concourse-tutorial
#
# NOTES
# This file is a self-contained description of a Concourse CI pipeline
# to deploy a http://gosparta.io application. There's a couple of things to
# note:
# - The YAML uses node references so that scripts can be defined in the
@mweagle
mweagle / main.go
Last active Aug 26, 2016
Spartav0.8.0_newCommand
View main.go
// Custom command to startup a simple HelloWorld HTTP server
sqsWorkerCommand := &cobra.Command{
Use: "sqsWorker",
Short: "Sample SQS Worker processor",
Long: fmt.Sprintf("Sample SQS listener"),
RunE: func(cmd *cobra.Command, args []string) error {
return sqsListener(sparta.OptionsGlobal.Logger)
},
}
sparta.CommandLineOptions.Root.AddCommand(sqsWorkerCommand)
@mweagle
mweagle / main.go
Created Aug 26, 2016
Spartav0.8.0_sshKeyName
View main.go
// And add the SSHKeyName option to the provision step
sparta.CommandLineOptions.Provision.Flags().StringVarP(&SSHKeyName,
"key",
"k",
"",
"SSH Key Name to use for EC2 instances")
@mweagle
mweagle / main.go
Created Aug 26, 2016
Spartav0.8.0_buildDockerImage
View main.go
// SpartaPostBuildDockerImageHook workflow hook to build the Docker image
func SpartaPostBuildDockerImageHook(context map[string]interface{},
serviceName string,
S3Bucket string,
buildID string,
awsSession *session.Session,
noop bool,
logger *logrus.Logger) error {
dockerServiceName := strings.ToLower(serviceName)
@mweagle
mweagle / main.go
Created Aug 26, 2016
Spartav0.8.0_newLambda
View main.go
// Setup an IAM role that allows the lambda function to send a message
// to the queue.
iamPolicy := sparta.IAMRoleDefinition{
Privileges: []sparta.IAMRolePrivilege{
sparta.IAMRolePrivilege{
Actions: []string{
"sqs:SendMessage"},
Resource: gocf.GetAtt(sqsResourceName, "Arn").String(),
},
},
@mweagle
mweagle / main.go
Last active Aug 26, 2016
Spartav0.8.0_EC2Role
View main.go
ec2IAMStatements = append(ec2IAMStatements, spartaIAM.PolicyStatement{
Action: []string{"sqs:ChangeMessageVisibility",
"sqs:DeleteMessage",
"sqs:GetQueueAttributes",
"sqs:ReceiveMessage"},
Effect: "Allow",
Resource: gocf.GetAtt(sqsResourceName, "Arn").String(),
@mweagle
mweagle / main.go
Last active Aug 26, 2016
Spartav0.8.0_envVars
View main.go
Environment: &gocf.EC2ContainerServiceTaskDefinitionContainerDefinitionsEnvironmentList{
gocf.EC2ContainerServiceTaskDefinitionContainerDefinitionsEnvironment{
Name: gocf.String("AWS_REGION"),
Value: gocf.Ref("AWS::Region").String(),
},
gocf.EC2ContainerServiceTaskDefinitionContainerDefinitionsEnvironment{
Name: gocf.String(sqsQueueURLEnvVar),
Value: gocf.Ref(sqsResourceName).String(),
},
gocf.EC2ContainerServiceTaskDefinitionContainerDefinitionsEnvironment{
View FnImport.go
lambdaFn.Decorator = func(serviceName string,
lambdaResourceName string,
lambdaResource gocf.LambdaFunction,
resourceMetadata map[string]interface{},
S3Bucket string,
S3Key string,
buildID string,
template *gocf.Template,
context map[string]interface{},
logger *logrus.Logger) error {
View GrafanaLookup.go
// Go get the outputs of the GrafanaStack
awsSession := session.New()
cloudFormationSvc := cloudformation.New(awsSession)
params := &cloudformation.DescribeStacksInput{
StackName: aws.String(GrafanaStackName),
}
outputResults, outputResultsErr := cloudFormationSvc.DescribeStacks(params)
You can’t perform that action at this time.