I am using aws cli to setup lifecycle management on a S3 bucket. I am using this json script:
{
"Rules": [
{
"Filter": {
},
"Status": "Enabled",
"Transitions": [
{
"Days": 30,
"StorageClass": "STANDARD_IA"
},
{
"Days": 365,
"StorageClass": "GLACIER"
}
],
"NoncurrentVersionTransitions": {
"NoncurrentDays": 30,
"StorageClass": "STANDARD_IA"
},
"Expiration": {
"Days": 3650
},
"ID": "Test"
}
]
}
and I am getting this error:
Parameter validation failed:
Invalid type for parameter
LifecycleConfiguration.Rules[0].NoncurrentVersionTransitions, value:
OrderedDict([(u'NoncurrentDays', 30), (u'StorageClass', u'STANDARD_IA')]),
type: <class 'collections.OrderedDict'>, valid types: <type 'list'>, <type
'tuple'>
The script works fine when I exclude the part about the NoncurrentVersionTransitions. I was wondering how I could include the NoncurrentVersionTransitions correctly.
Thanks in advance.
"NoncurrentVersionTransitions": {
"NoncurrentDays": 30,
"StorageClass": "STANDARD_IA"
},
replace with added []
"NoncurrentVersionTransitions": [{
"NoncurrentDays": 30,
"StorageClass": "STANDARD_IA"
}],
solves the issue.
Related
When running the following
aws glue create-crawler --debug --cli-input-json '{
"Name": "crawler",
"Role": "arn:...",
"DatabaseName": "db",
"Description": "table crawler",
"Targets": {
"CatalogTargets": [{
"DatabaseName": "db",
"Tables": ["tab"]
}]
},
"SchemaChangePolicy": {
"UpdateBehavior": "LOG",
"DeleteBehavior": "LOG"
},
"RecrawlPolicy": {
"RecrawlBehavior": "CRAWL_EVERYTHING"
},
"Configuration": {
"Version": 1.0,
"CrawlerOutput": {
"Partitions": { "AddOrUpdateBehavior": "InheritFromTable" }
},
"Grouping": { "TableGroupingPolicy": "CombineCompatibleSchemas" }
},
"Schedule": "Cron(1 * * * ? *)"
}'
It fails on
Parameter validation failed:
Invalid type for parameter Configuration, value: {'Version': 1.0, 'CrawlerOutput': {'Partitions': {'AddOrUpdateBehavior': 'InheritFromTable'}}, 'Grouping': {'TableGroupingPolicy': 'CombineCompatibleSchemas'}}, type: <class 'dict'>, valid types: <class 'str'>
I'm getting the format from here and if I remove Configuration it works. I tried all kind of quoting options to make this dictionary into one string but everything fails. Would love some help spotting the issue.
The solution is to move the configuration to an argument in that command
aws glue create-crawler --configuration '{
"Version": 1.0,
"CrawlerOutput": {
"Partitions": { "AddOrUpdateBehavior": "InheritFromTable" }
},
"Grouping": { "TableGroupingPolicy": "CombineCompatibleSchemas" }
}' --debug --cli-input-json '{
"Name": "crawler",
"Role": "arn:...",
"DatabaseName": "db",
"Description": "table crawler",
"Targets": {
"CatalogTargets": [{
"DatabaseName": "db",
"Tables": ["tab"]
}]
},
"SchemaChangePolicy": {
"UpdateBehavior": "LOG",
"DeleteBehavior": "LOG"
},
"RecrawlPolicy": {
"RecrawlBehavior": "CRAWL_EVERYTHING"
},
"Schedule": "Cron(1 * * * ? *)"
}'
Can anyone please guide me steps to create multiple triggers types one with conditional and other with scheduled trigger type in single workflow
So far I have used create_trigger function . But above requirement not sure how to address.
Can any one help here please.
I have tried with below syntax didn't work
response = client.create_trigger(
Name='two_triggers',
WorkflowName='wf_With_two_tirggers',
Type='SCHEDULED',
Schedule='cron(0 12 * * ? *)',
Actions=[
{
'JobName': 'abc_dev',
'Arguments': {
'string': 'string'
},
'Timeout': 123,
'SecurityConfiguration': 'string',
'NotificationProperty': {
'NotifyDelayAfter': 123
},
'Trigger': 'string'
},
],
Type='CONDITIONAL',
Predicate={
'Logical': 'ANY',
'Conditions': [
{
'LogicalOperator': 'EQUALS',
'JobName': 'def_dev',
'State': 'SUCCEEDED'
},
]
},
Actions=[
{
'JobName': 'ghi_dev',
'Arguments': {
'string': 'string'
},
'Timeout': 123,
'SecurityConfiguration': 'string',
'NotificationProperty': {
'NotifyDelayAfter': 123
},
'CrawlerName': 'string'
},
],
Description='string',
StartOnCreation=True,
Tags={
'string': 'string'
}
)
Below is the design workflow struggling to write code for. Tried with above code for below design using boto3 didn't work
Yes I figured out on an answer. Below is the code for design given in question
import boto3
import os
import logging
glue = boto3.client(service_name="glue", region_name='us-east-1')
response = glue.create_workflow(
Name="dual_trigger_wf")
response1 = glue.create_trigger(
Name="trigger_one_to_many",
WorkflowName="dual_trigger_wf",
Type="SCHEDULED",
Schedule="cron(0 8 * * ? *)",
Actions=[
{
"JobName": "abc",
"Arguments": {"string": "string"},
"Timeout": 123,
"SecurityConfiguration": "string",
"NotificationProperty": {"NotifyDelayAfter": 123},
},
{
"JobName": "def",
"Arguments": {"string": "string"},
"Timeout": 123,
"SecurityConfiguration": "string",
"NotificationProperty": {"NotifyDelayAfter": 123},
},
],
Description="string",
StartOnCreation=False,
)
response2 = glue.create_trigger(
Name="trigger_many_to_one",
WorkflowName="dual_trigger_wf",
Type="CONDITIONAL",
Predicate={
"Logical": "AND",
"Conditions": [
{
"LogicalOperator": "EQUALS",
"JobName": "abc",
"State": "SUCCEEDED",
},
{
"LogicalOperator": "EQUALS",
"JobName": "def",
"State": "SUCCEEDED",
},
],
},
Actions=[
{
"JobName": "ghi",
"Arguments": {"string": "string"},
"Timeout": 123,
"SecurityConfiguration": "string",
"NotificationProperty": {"NotifyDelayAfter": 123},
}
],
Description="string",
StartOnCreation=False,
)
I am trying to create Amazon Connect Contact flows using the cloudformation template and Amazon Contact flow language which is new for me. But I am
facing this issue and the stack fails to create. I am not sure If I am having syntax errors in my yml file.
Complete error message
Resource handler returned message: "Invalid request (Service: Connect, Status Code: 400, Request ID: aa1e1049-47bb-43ea-8065-0f8b1cf503d2)" (RequestToken: ff62940b-0e60-2308-d33d-917eeb399402, HandlerErrorCode: InvalidRequest)
Here is the cloud formation template
---
AWSTemplateFormatVersion: "2010-09-09"
Description: "Amazon Connect - Contact Flow"
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
default: "General Information"
Parameters:
- SystemName
- EnvironmentName
- Label:
default: "Amazon Connect Information"
Parameters:
- InstanceID
- ContactFlowName
Parameters:
SystemName:
Type: String
EnvironmentName:
Type: String
AllowedValues: [prd, stg, dev]
InstanceID:
Type: String
Description: "Enter the Amazon Connect Instance ID (e.g. 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx')"
ContactFlowName:
Type: String
Description: "Enter the Name of the Contact flow"
Resources:
ContactFlow:
Type: 'AWS::Connect::ContactFlow'
Properties:
Name: !Sub "${ContactFlowName}"
Description: Example contact flow
InstanceArn: !Sub "arn:aws:connect:${AWS::Region}:${AWS::AccountId}:instance/${InstanceID}"
Type: CONTACT_FLOW
Content: |
{
"Version": "2019-10-30",
"StartAction": "c8275c19-08aa-4ee5-9b42-bcc47d32e914",
"Metadata": {
"entryPointPosition": {
"x": 20,
"y": 20
},
"snapToGrid": false,
"ActionMetadata": {
"5c47b68e-d790-45eb-a0bd-654027af4868": {
"position": {
"x": 463,
"y": 491
},
"useDynamic": false
},
"c8275c19-08aa-4ee5-9b42-bcc47d32e914": {
"position": {
"x": 180,
"y": 20
},
"conditionMetadata": [
{
"id": "6a7b09ef-d441-4183-8ef3-2f0f360ba747",
"value": "1"
},
{
"id": "f3516737-c758-4d6f-8d31-ea43d1e27990",
"value": "2"
},
{
"id": "21ad3977-2559-4449-ba54-b84d4a0521b6",
"value": "3"
}
],
"useDynamic": false,
"useLexBotDropdown": true,
"useDynamicLexBotArn": false
},
"c36d9f86-780d-4c44-8c79-80c8353a699a": {
"position": {
"x": 1068,
"y": 317
}
},
"14837518-cc08-4d54-ac93-ea7e063481a8": {
"position": {
"x": 492,
"y": 340
},
"overrideConsoleVoice": false,
"defaultVoice": "Standard"
},
"1e435e5f-7b62-4938-8c9f-fa05106c72b3": {
"position": {
"x": 501,
"y": 174
},
"overrideConsoleVoice": false,
"defaultVoice": "Standard"
},
"98768cdb-f5e6-4642-90e3-6e06fd6813e8": {
"position": {
"x": 478,
"y": 21
},
"overrideConsoleVoice": false,
"defaultVoice": "Conversational",
"fragments": {
"SetContactData": "bc981918-e0b3-4840-afa5-12b6d7078248"
}
},
"bc981918-e0b3-4840-afa5-12b6d7078248": {
"position": {
"x": 0,
"y": 0
}
},
"3a521089-edfe-4821-8156-19014b7b8926": {
"position": {
"x": 716,
"y": 45
},
"useDynamic": false,
"ContactFlow": {
"id": "arn:aws:connect:eu-central-1:132387760551:instance/a65f970f-0f59-444e-b421-5ec6ec74c116/contact-flow/d727e34f-6707-437f-8013-20e4f2a867d6",
"text": "Transaction Banking Authentication"
}
}
}
},
"Actions": [
{
"Identifier": "5c47b68e-d790-45eb-a0bd-654027af4868",
"Parameters": {
"Text": "An Error Occured!"
},
"Transitions": {
"NextAction": "c36d9f86-780d-4c44-8c79-80c8353a699a",
"Errors": [
{
"NextAction": "c36d9f86-780d-4c44-8c79-80c8353a699a",
"ErrorType": "NoMatchingError"
}
],
"Conditions": []
},
"Type": "MessageParticipant"
},
{
"Identifier": "c8275c19-08aa-4ee5-9b42-bcc47d32e914",
"Parameters": {
"Text": "To continue in English press 1, Ukuqhubeka ngesiZulu cindezela u- 2, Vir Afrikaans Druk 3.",
"StoreInput": "False",
"InputTimeLimitSeconds": "5"
},
"Transitions": {
"NextAction": "5c47b68e-d790-45eb-a0bd-654027af4868",
"Errors": [
{
"NextAction": "5c47b68e-d790-45eb-a0bd-654027af4868",
"ErrorType": "NoMatchingError"
},
{
"NextAction": "5c47b68e-d790-45eb-a0bd-654027af4868",
"ErrorType": "NoMatchingCondition"
},
{
"NextAction": "5c47b68e-d790-45eb-a0bd-654027af4868",
"ErrorType": "InputTimeLimitExceeded"
}
],
"Conditions": [
{
"NextAction": "98768cdb-f5e6-4642-90e3-6e06fd6813e8",
"Condition": {
"Operator": "Equals",
"Operands": [
"1"
]
}
},
{
"NextAction": "1e435e5f-7b62-4938-8c9f-fa05106c72b3",
"Condition": {
"Operator": "Equals",
"Operands": [
"2"
]
}
},
{
"NextAction": "14837518-cc08-4d54-ac93-ea7e063481a8",
"Condition": {
"Operator": "Equals",
"Operands": [
"3"
]
}
}
]
},
"Type": "GetParticipantInput"
},
{
"Identifier": "c36d9f86-780d-4c44-8c79-80c8353a699a",
"Type": "DisconnectParticipant",
"Parameters": {},
"Transitions": {}
},
{
"Identifier": "14837518-cc08-4d54-ac93-ea7e063481a8",
"Parameters": {
"TextToSpeechVoice": "Lotte"
},
"Transitions": {
"NextAction": "3a521089-edfe-4821-8156-19014b7b8926",
"Errors": [],
"Conditions": []
},
"Type": "UpdateContactTextToSpeechVoice"
},
{
"Identifier": "1e435e5f-7b62-4938-8c9f-fa05106c72b3",
"Parameters": {
"TextToSpeechVoice": "Marlene"
},
"Transitions": {
"NextAction": "3a521089-edfe-4821-8156-19014b7b8926",
"Errors": [],
"Conditions": []
},
"Type": "UpdateContactTextToSpeechVoice"
},
{
"Identifier": "98768cdb-f5e6-4642-90e3-6e06fd6813e8",
"Parameters": {
"TextToSpeechVoice": "Joanna"
},
"Transitions": {
"NextAction": "bc981918-e0b3-4840-afa5-12b6d7078248",
"Errors": [],
"Conditions": []
},
"Type": "UpdateContactTextToSpeechVoice"
},
{
"Identifier": "bc981918-e0b3-4840-afa5-12b6d7078248",
"Parameters": {
"LanguageCode": "en-US"
},
"Transitions": {
"NextAction": "3a521089-edfe-4821-8156-19014b7b8926",
"Errors": [
{
"NextAction": "3a521089-edfe-4821-8156-19014b7b8926",
"ErrorType": "NoMatchingError"
}
],
"Conditions": []
},
"Type": "UpdateContactData"
},
{
"Identifier": "3a521089-edfe-4821-8156-19014b7b8926",
"Parameters": {
"ContactFlowId": "arn:aws:connect:eu-central-1:132387760551:instance/a65f970f-0f59-444e-b421-5ec6ec74c116/contact-flow/d727e34f-6707-437f-8013-20e4f2a867d6"
},
"Transitions": {
"NextAction": "c36d9f86-780d-4c44-8c79-80c8353a699a",
"Errors": [
{
"NextAction": "c36d9f86-780d-4c44-8c79-80c8353a699a",
"ErrorType": "NoMatchingError"
}
],
"Conditions": []
},
"Type": "TransferToFlow"
}
]
Tags:
- Key: System
Value: !Ref SystemName
- Key: Environment
Value: !Ref EnvironmentName
Any kinda help will Appreciated
Okay, looks like the Content object is not valid. For starters it ends with a ] character instead of a } But even fixing that it has issues.
I'd suggest creating a flow in the gui and export it, then use the json from that as a template.
Also, check the Flow language documentation to get the syntax and structure correct.
haii, i have the awscli result describing the target group as json format
{
"TargetHealthDescriptions": [
{
"Target": {
"Id": "1.1.1.1",
"Port": 123,
"AvailabilityZone": "ap-south-1"
},
"HealthCheckPort": "123",
"TargetHealth": {
"State": "healthy"
}
},
{
"Target": {
"Id": "2.2.2.2",
"Port": 123,
"AvailabilityZone": "ap-south-1"
},
"HealthCheckPort": "123",
"TargetHealth": {
"State": "healthy"
}
}
]
}
Im trying to make an awscli script to get a result like this
[
{
"Id": "1.1.1.1",
"Port": 123,
"Health": null
},
{
"Id": "2.2.2.2",
"Port": 123,
"Health": null
}
]
I've tried several query methods but I have problems getting a null value for health, its any errors in the query ?
ex query
--query 'TargetHealthDescriptions[*].Target.{Id:Id, Port:Port, Health:TargetHealth.{state:State}}' --output json
Try the below:
--query 'TargetHealthDescriptions[*].{Id:Target.Id,Port:Target.Port,Health:TargetHealth.State}'
Been trying to create a cloud formation template. I have been trying to use the UserData section and have reduced the template to the bones to identify what the problem is:
I am getting the error: Property validation failure: [Encountered unsupported properties in {/}: [UserData]]
This is my now totally barebones template. I must be doing something fundamentally wrong. Can someone help please?
{
"AWSTemplateFormatVersion": "2010-09-09",
"Metadata": {
"AWS::CloudFormation::Designer": {
"319ac38d-a9ea-4855-9a9a-4dc91f6ef092": {
"size": {
"width": 60,
"height": 60
},
"position": {
"x": -310,
"y": 30
},
"z": 1,
"embeds": []
}
}
},
"Resources": {
"Cloud9Template": {
"Type": "AWS::Cloud9::EnvironmentEC2",
"Properties": {
"UserData":{
"Fn::Base64" : {
"Fn::Join" : [ ",", [
"test",
"Hello World" ] ]
}
},
"AutomaticStopTimeMinutes": "45",
"InstanceType": "t2.micro",
"Name": {
"Ref": "AWS::StackName"
}
},
"Metadata": {
"AWS::CloudFormation::Designer": {
"id": "319ac38d-a9ea-4855-9a9a-4dc91f6ef092"
},
"AWS::CloudFormation::Init" : {
"sources" : {
"/home/ec2-user/environment/src" : <linktotarball>"
}
}
}
}
}
}
Thank you!
Unfortunately, AWS::Cloud9::EnvironmentEC2 does not support UserData as shown in its documentation.
In other words, you can't use UserData in the definition of EnvironmentEC2 resource.