### S3 Quick Start Example Source: https://ministack.org/docs/services/s3.html A quick start example demonstrating how to use the boto3 library to interact with the S3 service, including creating a bucket, putting an object, and getting an object. ```APIDOC ## Quick start ``` import boto3 s3 = boto3.client("s3", endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test") s3.create_bucket(Bucket="demo") s3.put_object(Bucket="demo", Key="hi.txt", Body=b"hello") print(s3.get_object(Bucket="demo", Key="hi.txt")["Body"].read()) ``` ``` -------------------------------- ### Step Functions Quick Start Source: https://ministack.org/docs/services/stepfunctions.html Quick start example demonstrating how to create a Step Functions state machine and start an execution using the boto3 client. Requires boto3 and json libraries. ```python import boto3, json sfn = boto3.client("stepfunctions", endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test") sm = sfn.create_state_machine(Name="demo", RoleArn="arn:aws:iam::000000000000:role/r", Definition=json.dumps({"StartAt":"Done","States":{"Done":{"Type":"Pass","End":True}}})) sfn.start_execution(stateMachineArn=sm["stateMachineArn"]) ``` -------------------------------- ### SES Quick Start with boto3 Source: https://ministack.org/docs/services/ses.html A quick start example demonstrating how to use the boto3 library to interact with the SES service, including verifying an email identity and sending a simple email. ```APIDOC ## Quick start ```python import boto3 ses = boto3.client("ses", endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test") ses.verify_email_identity(EmailAddress="me@example.com") ses.send_email(Source="me@example.com", Destination={"ToAddresses":["you@example.com"]}, Message={"Subject":{"Data":"hi"},"Body":{"Text":{"Data":"hello"}}}) ``` ``` -------------------------------- ### EC2 Quick Start Example Source: https://ministack.org/docs/services/ec2.html This snippet demonstrates how to initialize the EC2 client with MiniStack and create a VPC. It then prints the existing VPCs. ```python import boto3 ec2 = boto3.client("ec2", endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test") vpc = ec2.create_vpc(CidrBlock="10.0.0.0/16")["Vpc"] print(ec2.describe_vpcs()["Vpcs"]) ``` -------------------------------- ### S3 Quick Start Example Source: https://ministack.org/docs/services/s3.html Demonstrates how to initialize an S3 client and perform basic operations like creating a bucket, uploading an object, and retrieving it. Ensure MiniStack is running and accessible. ```python import boto3 s3 = boto3.client("s3", endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test") s3.create_bucket(Bucket="demo") s3.put_object(Bucket="demo", Key="hi.txt", Body=b"hello") print(s3.get_object(Bucket="demo", Key="hi.txt")["Body"].read()) ``` -------------------------------- ### DynamoDB Quick Start with Boto3 Source: https://ministack.org/docs/services/dynamodb.html This snippet demonstrates how to initialize a Boto3 DynamoDB client, create a table, and put an item into it. It's useful for getting started with DynamoDB locally using MiniStack. ```python import boto3 ddb = boto3.client("dynamodb", endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test") ddb.create_table(TableName="t", KeySchema=[{"AttributeName":"pk","KeyType":"HASH"}], AttributeDefinitions=[{"AttributeName":"pk","AttributeType":"S"}], BillingMode="PAY_PER_REQUEST") ddb.put_item(TableName="t", Item={"pk":{"S":"k1"},"data":{"S":"v1"}}) ``` -------------------------------- ### SNS Quick Start Example Source: https://ministack.org/docs/services/sns.html Demonstrates how to initialize the SNS client, create a topic, and publish a message using the AWS SDK for Python (boto3). ```python import boto3 sns = boto3.client("sns", endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test") topic = sns.create_topic(Name="events")["TopicArn"] sns.publish(TopicArn=topic, Message="hello") ``` -------------------------------- ### Create CodeBuild Project Source: https://ministack.org/docs/services/codebuild.html Quick start example to create a CodeBuild project using boto3. Ensure you have the boto3 library installed and configured for local testing with MiniStack. ```python import boto3 cb = boto3.client("codebuild", endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test") cb.create_project(name="demo", source={"type":"NO_SOURCE"}, artifacts={"type":"NO_ARTIFACTS"}, environment={"type":"LINUX_CONTAINER", "image":"aws/codebuild/amazonlinux2-x86_64-standard:5.0", "computeType":"BUILD_GENERAL1_SMALL"}, serviceRole="arn:aws:iam::000000000000:role/r") ``` -------------------------------- ### KMS Quick Start Example Source: https://ministack.org/docs/services/kms.html Demonstrates how to initialize the KMS client, create a key, encrypt data, and decrypt it using the boto3 library. Ensure the local endpoint is configured correctly. ```python import boto3 kms = boto3.client("kms", endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test") k = kms.create_key()["KeyMetadata"] ct = kms.encrypt(KeyId=k["KeyId"], Plaintext=b"secret")["CiphertextBlob"] print(kms.decrypt(CiphertextBlob=ct)["Plaintext"]) ``` -------------------------------- ### Create ECR Repository Source: https://ministack.org/docs/services/ecr.html Quick start example to create an ECR client and a repository named 'app'. Ensure MiniStack is running and accessible. ```python import boto3 ecr = boto3.client("ecr", endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test") ecr.create_repository(repositoryName="app") ``` -------------------------------- ### SQS Quick Start Example Source: https://ministack.org/docs/services/sqs.html This snippet demonstrates how to set up an SQS client, create a queue, send a message, and receive a message using boto3. Ensure the localstack endpoint and credentials are correctly configured. ```python import boto3 sqs = boto3.client("sqs", endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test") q = sqs.create_queue(QueueName="jobs")["QueueUrl"] sqs.send_message(QueueUrl=q, MessageBody="ping") print(sqs.receive_message(QueueUrl=q)["Messages"][0]["Body"]) ``` -------------------------------- ### Quick Start: SSM Parameter Store Operations Source: https://ministack.org/docs/services/ssm.html Demonstrates how to initialize the SSM client and perform basic operations like putting and getting a parameter. Ensure the MiniStack service is running and accessible via the specified endpoint. ```python import boto3 ssm = boto3.client("ssm", endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test") ssm.put_parameter(Name="/app/db", Value="jdbc:...", Type="String") print(ssm.get_parameter(Name="/app/db")["Parameter"]["Value"]) ``` -------------------------------- ### Create RDS DB Instance Source: https://ministack.org/docs/services/rds.html Quick start example to create a PostgreSQL DB instance using boto3. Ensure the RDS endpoint and region are correctly configured. ```python import boto3 rds = boto3.client("rds", endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test") rds.create_db_instance(DBInstanceIdentifier="db", Engine="postgres", EngineVersion="15", MasterUsername="admin", MasterUserPassword="pw123456", DBInstanceClass="db.t3.micro", AllocatedStorage=20) ``` -------------------------------- ### Create REST API with SDK Source: https://ministack.org/docs/services/apigateway.html Quick start example demonstrating how to create a REST API using the AWS SDK's apigateway client. This is useful for programmatically setting up APIs. ```python import boto3 api = boto3.client("apigateway", endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test") r = api.create_rest_api(name="demo") ``` -------------------------------- ### CloudWatch Quick Start Source: https://ministack.org/docs/services/cloudwatch.html Initializes the CloudWatch client and puts sample metric data. Ensure the endpoint URL and credentials are set correctly for your environment. ```python import boto3 cw = boto3.client("cloudwatch", endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test") cw.put_metric_data(Namespace="App", MetricData=[{"MetricName":"hits","Value":1}]) ``` -------------------------------- ### Create AppSync GraphQL API Source: https://ministack.org/docs/services/appsync.html Quick start example to create a GraphQL API using the AWS SDK. Ensure the AppSync client is configured with the correct endpoint and credentials. ```python import boto3 sync = boto3.client("appsync", endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test") sync.create_graphql_api(name="demo", authenticationType="API_KEY") ``` -------------------------------- ### Set Athena Engine to DuckDB Source: https://ministack.org/docs/configuration.html This example shows how to use the runtime configuration endpoint to set the Athena engine to use DuckDB. This requires DuckDB to be installed. ```bash curl -X POST http://localhost:4566/_ministack/config \ -H 'Content-Type: application/json' \ -d '{"key":"athena.engine","value":"duckdb"}' ``` -------------------------------- ### S3 Files (compat) Quick Start Source: https://ministack.org/docs/services/s3-files.html This is a deprecated quick start command. It is recommended to use S3 and EFS service pages for new work. ```bash # Deprecated; prefer S3 + EFS service pages for new work. ``` -------------------------------- ### Create Transfer Family Server Source: https://ministack.org/docs/services/transfer.html Quick start example to create an SFTP server using the boto3 client. Ensure the endpoint URL and region are correctly configured for your environment. ```python import boto3 tf = boto3.client("transfer", endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test") tf.create_server(Protocols=["SFTP"], IdentityProviderType="SERVICE_MANAGED") ``` -------------------------------- ### AWS CDK Local Setup and Deployment Source: https://ministack.org/docs/iac.html Install and use the `cdklocal` wrapper for AWS CDK v1 and v2. This injects the necessary endpoint URL and defaults for local development. ```bash npm install -g aws-cdk-local cdklocal bootstrap cdklocal deploy ``` -------------------------------- ### Quick Start: Execute a Query with Athena Source: https://ministack.org/docs/services/athena.html This snippet demonstrates how to initiate a query execution and retrieve results using the boto3 client for Athena. Ensure you have the boto3 library installed and configured for your environment. ```python import boto3 ath = boto3.client("athena", endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test") q = ath.start_query_execution(QueryString="SELECT 1", ResultConfiguration={"OutputLocation":"s3://out/"}) print(ath.get_query_results(QueryExecutionId=q["QueryExecutionId"])) ``` -------------------------------- ### Firehose Quick Start Source: https://ministack.org/docs/services/firehose.html Demonstrates how to initialize the Firehose client and create a delivery stream to S3. This snippet requires the boto3 library and assumes a local endpoint for MiniStack. ```python import boto3 fh = boto3.client("firehose", endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test") fh.create_delivery_stream(DeliveryStreamName="d", S3DestinationConfiguration={"RoleARN":"arn:...","BucketARN":"arn:aws:s3:::bkt"}) fh.put_record(DeliveryStreamName="d", Record={"Data":b"hello"}) ``` -------------------------------- ### Install Testcontainers, Boto3, Pytest, and Requests Source: https://ministack.org/docs/testcontainers-python.html Install the necessary Python packages for testing with Testcontainers and MiniStack. ```bash pip install "testcontainers>=4" boto3 pytest requests ``` -------------------------------- ### SES Quick Start with Boto3 Source: https://ministack.org/docs/services/ses.html This snippet demonstrates how to initialize the Boto3 SES client to point to a local endpoint and perform basic operations like verifying an email identity and sending a simple email. ```python import boto3 ses = boto3.client("ses", endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test") ses.verify_email_identity(EmailAddress="me@example.com") ses.send_email(Source="me@example.com", Destination={"ToAddresses":["you@example.com"]}, Message={"Subject":{"Data":"hi"},"Body":{"Text":{"Data":"hello"}}}) ``` -------------------------------- ### Kinesis Quick Start Source: https://ministack.org/docs/services/kinesis.html Initializes the Kinesis client and creates a stream with one shard, then puts a record into it. Use this to quickly set up and test Kinesis stream operations. ```python import boto3 kin = boto3.client("kinesis", endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test") kin.create_stream(StreamName="s", ShardCount=1) kin.put_record(StreamName="s", Data=b"hello", PartitionKey="k") ``` -------------------------------- ### Quick Start: Initialize Glue Client and Create Database/Table Source: https://ministack.org/docs/services/glue.html Initializes the AWS Glue client using boto3 and demonstrates creating a database and a table within it. This is useful for setting up a basic Glue environment for testing or development. ```python import boto3 glue = boto3.client("glue", endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test") glue.create_database(DatabaseInput={"Name":"db"}) glue.create_table(DatabaseName="db", TableInput={"Name":"t","StorageDescriptor":{"Columns":[{"Name":"c","Type":"string"}]}}) ``` -------------------------------- ### Quick Start: Create and Retrieve a Secret Source: https://ministack.org/docs/services/secretsmanager.html This snippet demonstrates how to initialize the Secrets Manager client and perform basic operations like creating and retrieving a secret using boto3. ```python import boto3 sm = boto3.client("secretsmanager", endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test") sm.create_secret(Name="db-pass", SecretString="hunter2") print(sm.get_secret_value(SecretId="db-pass")["SecretString"]) ``` -------------------------------- ### Quick Start: Create Auto Scaling Group and Launch Configuration Source: https://ministack.org/docs/services/autoscaling.html This snippet demonstrates how to create a launch configuration and an Auto Scaling group using the boto3 client. Ensure you have the necessary AWS credentials and endpoint configured. ```python import boto3 asg = boto3.client("autoscaling", endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test") asg.create_launch_configuration(LaunchConfigurationName="lc", ImageId="ami-000", InstanceType="t3.micro") asg.create_auto_scaling_group(AutoScalingGroupName="g", LaunchConfigurationName="lc", MinSize=1, MaxSize=3, AvailabilityZones=["us-east-1a"]) ``` -------------------------------- ### Connect to Real RDS Instance Source: https://ministack.org/docs Connect to a real RDS Postgres instance started by MiniStack using psql. ```bash # After creating the instance: psql -h localhost -p 15432 -U admin -d mydb ``` -------------------------------- ### Quick Start: Initialize CloudFront Client Source: https://ministack.org/docs/services/cloudfront.html Initializes the CloudFront client using boto3, specifying a local endpoint for testing. This is useful for setting up interactions with the CloudFront service in a development environment. ```python import boto3 cf = boto3.client("cloudfront", endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test") cf.list_distributions() ``` -------------------------------- ### Docker Compose for MiniStack Source: https://ministack.org/docs/migrating-from-localstack.html Example Docker Compose configuration for running MiniStack, demonstrating image swap and environment variable mapping from LocalStack. ```yaml services: ministack: image: ministackorg/ministack:latest ports: - "4566:4566" environment: - PERSIST_STATE=1 # was LOCALSTACK_PERSISTENCE (still honored) - LAMBDA_EXECUTOR=docker - DOCKER_NETWORK=myapp_default volumes: - /var/run/docker.sock:/var/run/docker.sock - ./data/state:/tmp/ministack-state - ./data/s3:/tmp/ministack-data/s3 ``` -------------------------------- ### Quick Start: Create ECS Cluster, Task Definition, and Run Task Source: https://ministack.org/docs/services/ecs.html This Python snippet demonstrates how to use the boto3 library to create an ECS cluster, register a task definition, and run a task. It requires the MiniStack endpoint and credentials. ```python import boto3 ecs = boto3.client("ecs", endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test") ecs.create_cluster(clusterName="c") td = ecs.register_task_definition(family="hello", containerDefinitions=[ {"name":"h","image":"hello-world","essential":True}]) ecs.run_task(cluster="c", taskDefinition=td["taskDefinition"]["taskDefinitionArn"]) ``` -------------------------------- ### Quick Start: Initialize AppConfig Client Source: https://ministack.org/docs/services/appconfig.html Initializes the AppConfig client using boto3, specifying a local endpoint for testing. This is useful for setting up a client to interact with a local or mock AWS environment. ```python import boto3 ac = boto3.client("appconfig", endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test") ac.create_application(Name="web") ``` -------------------------------- ### Create an EventBridge Pipe Source: https://ministack.org/docs/services/pipes.html This snippet demonstrates how to create a basic EventBridge Pipe using the boto3 SDK. Ensure you have the boto3 library installed and configured for your environment. ```python import boto3 pipes = boto3.client("pipes", endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test") pipes.create_pipe(Name="p", Source="arn:aws:sqs:us-east-1:000000000000:in", Target="arn:aws:sqs:us-east-1:000000000000:out", RoleArn="arn:aws:iam::000000000000:role/r") ``` -------------------------------- ### Test DynamoDB Operations with Factory Fixture Source: https://ministack.org/docs/testcontainers-python.html An example test function demonstrating how to use the `aws` factory fixture to create a DynamoDB client and perform operations. ```python def test_dynamodb(aws): ddb = aws("dynamodb") ddb.create_table(...) ``` -------------------------------- ### Docker Compose Setup for MiniStack with Lambda Support Source: https://ministack.org/docs A Docker Compose configuration for running MiniStack with persistence enabled for state, S3, and RDS. Includes Lambda execution via Docker. ```yaml services: ministack: image: ministackorg/ministack:latest ports: - "4566:4566" environment: - PERSIST_STATE=1 - S3_PERSIST=1 - RDS_PERSIST=1 - LOG_LEVEL=INFO - LAMBDA_EXECUTOR=docker - LAMBDA_DOCKER_NETWORK=myproject_default volumes: - ./data/state:/tmp/ministack-state - ./data/s3:/tmp/ministack-data/s3 - /var/run/docker.sock:/var/run/docker.sock healthcheck: test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:4566/_ministack/health')"] interval: 10s timeout: 3s retries: 3 ``` -------------------------------- ### Quick Start: Execute SQL with RDS Data API Source: https://ministack.org/docs/services/rds-data.html This snippet demonstrates how to initialize the RDS Data API client and execute a simple SQL query. Ensure you have the necessary RDS cluster and secrets manager ARNs. ```python import boto3 rd = boto3.client("rds-data", endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test") rd.execute_statement( resourceArn="arn:aws:rds:us-east-1:000000000000:cluster:demo", secretArn="arn:aws:secretsmanager:us-east-1:000000000000:secret:demo", database="postgres", sql="SELECT 1") ``` -------------------------------- ### Quick Start: Create and Invoke Lambda Function Locally Source: https://ministack.org/docs/services/lambda.html This snippet demonstrates how to create and invoke a Python Lambda function locally using boto3. It includes setting up the Lambda client, creating a zip archive for the function code, and invoking the function. ```python import boto3, io, zipfile zf = io.BytesIO() with zipfile.ZipFile(zf, "w") as z: z.writestr("app.py", "def handler(e, c): return {'ok': True}") lam = boto3.client("lambda", endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test") lam.create_function(FunctionName="f", Runtime="python3.11", Role="arn:aws:iam::000000000000:role/r", Handler="app.handler", Code={"ZipFile": zf.getvalue()}) print(lam.invoke(FunctionName="f")["Payload"].read()) ``` -------------------------------- ### Create ElastiCache Cluster Source: https://ministack.org/docs/services/elasticache.html Quick start example to create a Redis cache cluster using boto3. Ensure the ElastiCache client is configured with the correct endpoint URL and credentials for MiniStack. ```python import boto3 ec = boto3.client("elasticache", endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test") ec.create_cache_cluster(CacheClusterId="r", Engine="redis", CacheNodeType="cache.t3.micro", NumCacheNodes=1) ``` -------------------------------- ### Quick Start: Initialize STS Client and Get Caller Identity Source: https://ministack.org/docs/services/sts.html Initializes the STS client using boto3 for a local endpoint and retrieves the caller's identity. Ensure the local endpoint and credentials are correctly configured. ```python import boto3 sts = boto3.client("sts", endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test") print(sts.get_caller_identity()) ``` -------------------------------- ### VerifyEmailIdentity Operation Source: https://ministack.org/docs/services/ses.html Starts the process of verifying email identity. You can verify a single email address or a domain. ```APIDOC ## VerifyEmailIdentity ### Description Starts the process of verifying an email identity. This operation is asynchronous; it returns a response to you without waiting for the verification process to complete. ### Method POST ### Endpoint / ### Parameters #### Query Parameters - **EmailAddress** (string) - Required - The email address to verify. ### Request Example ```json { "EmailAddress": "me@example.com" } ``` ### Response #### Success Response (200) This operation returns a JSON object containing a VerificationToken. - **VerificationToken** (string) - The verification token for the email identity. This is only returned when you verify an email address. #### Response Example ```json { "VerificationToken": "verification_token_string" } ``` ``` -------------------------------- ### Create EFS File System and Mount Target Source: https://ministack.org/docs/services/efs.html This snippet demonstrates how to create an EFS file system and a corresponding mount target using the boto3 client. It's useful for setting up basic EFS infrastructure programmatically. ```python import boto3 efs = boto3.client("efs", endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test") fs = efs.create_file_system(CreationToken="t") efs.create_mount_target(FileSystemId=fs["FileSystemId"], SubnetId="subnet-1") ``` -------------------------------- ### Connect to Real ElastiCache Instance Source: https://ministack.org/docs Connect to a real ElastiCache Redis instance started by MiniStack using redis-cli. ```bash redis-cli -p 16379 127.0.0.1:16379> SET hello world OK ``` -------------------------------- ### Test S3 Put and Get Operations Source: https://ministack.org/docs/testcontainers-python.html A test function that uses the `s3` fixture to create a bucket, put an object, and then retrieve it, asserting its content. ```python def test_put_get(s3): s3.create_bucket(Bucket="demo") s3.put_object(Bucket="demo", Key="hi.txt", Body=b"hello") body = s3.get_object(Bucket="demo", Key="hi.txt")["Body"].read() assert body == b"hello" ``` -------------------------------- ### Run EMR Job Flow Source: https://ministack.org/docs/services/emr.html Initiates an EMR job flow with specified configurations. Ensure you have the boto3 library installed and configured with appropriate credentials and endpoint. ```python import boto3 emr = boto3.client("emr", endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test") emr.run_job_flow(Name="c", ReleaseLabel="emr-6.15.0", Instances={"MasterInstanceType":"m5.xlarge","SlaveInstanceType":"m5.xlarge", "InstanceCount":1}, JobFlowRole="r", ServiceRole="s") ``` -------------------------------- ### Initialize and Use MiniStack with Testcontainers in Java Source: https://ministack.org/docs Initialize a MiniStack container and configure an S3 client for testing. ```java try (MiniStackContainer ms = new MiniStackContainer()) { ms.start(); S3Client s3 = S3Client.builder() .endpointOverride(URI.create(ms.getEndpoint())) .region(Region.of(ms.getRegion())) .credentialsProvider(StaticCredentialsProvider.create( AwsBasicCredentials.create(ms.getAccessKey(), ms.getSecretKey()))) .build(); // ... your test } ``` -------------------------------- ### Quick Start: Initialize CloudWatch Logs Client and Create Log Group/Stream Source: https://ministack.org/docs/services/cloudwatch-logs.html This snippet demonstrates how to initialize the CloudWatch Logs client using boto3 and perform basic operations like creating a log group, log stream, and putting log events. It's useful for setting up logging in a new application or environment. ```python import boto3 logs = boto3.client("logs", endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test") logs.create_log_group(logGroupName="/app") logs.create_log_stream(logGroupName="/app", logStreamName="main") logs.put_log_events(logGroupName="/app", logStreamName="main", logEvents=[{"timestamp": 1, "message": "hello"}]) ``` -------------------------------- ### Initialize EventBridge Client and Create Rule/Event Source: https://ministack.org/docs/services/eventbridge.html This snippet demonstrates how to initialize the EventBridge client using boto3 with a local endpoint and then create a rule and put an event. ```python import boto3 eb = boto3.client("events", endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test") eb.put_rule(Name="r", EventPattern='{"source":["myapp"]}') eb.put_events(Entries=[{"Source":"myapp","DetailType":"x","Detail":"{}"}]) ``` -------------------------------- ### Create IAM Role and Get ARN Source: https://ministack.org/docs/services/iam.html Demonstrates how to create an IAM role using boto3 and retrieve its Amazon Resource Name (ARN). This is useful for setting up roles for services or applications. ```python import boto3 iam = boto3.client("iam", endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test") iam.create_role(RoleName="r", AssumeRolePolicyDocument="{}") print(iam.get_role(RoleName="r")["Role"]["Arn"]) ```