Header menu logo FsCDK

IAM IAM (Identity and Access Management) Best Practices for FsCDK

IAM Authorization

AWS Identity and Access Management (IAM) is the foundation of AWS security. As AWS Hero Ben Kehoe states: "IAM isn't complicated—it's just misunderstood." This portal enhances FsCDK's IAM docs with insights from heroes like Ben Kehoe, Scott Piper, and Yan Cui. Includes narratives, checklists, drills, and resources (4.5+ rated, highly viewed).

Principle of Least Privilege

Always grant only the permissions required to perform a task—this is core to zero-trust security.

Lambda Function Roles

#r "../src/bin/Release/net8.0/publish/Amazon.JSII.Runtime.dll"
#r "../src/bin/Release/net8.0/publish/Constructs.dll"
#r "../src/bin/Release/net8.0/publish/Amazon.CDK.Lib.dll"
#r "../src/bin/Release/net8.0/publish/System.Text.Json.dll"
#r "../src/bin/Release/net8.0/publish/FsCDK.dll"

open FsCDK
open Amazon.CDK
open Amazon.CDK.AWS.Lambda
open Amazon.CDK.AWS.IAM

❌ BAD: Too permissive

Don't grant Lambda full access to everything:

// This grants the Lambda full access to everything!
lambda "MyFunction" {
    runtime Runtime.DOTNET_8
    handler "MyApp::Handler"
    code "./publish"

// role adminRole  // Don't do this!
}

❌ CRITICAL ERROR: Wildcard Actions AND Resources

FsCDK now blocks this at compile time:

// This will FAIL compilation with security error:
policyStatement {
    actions [ "*" ]       // ❌ Wildcard actions
    resources [ "*" ]     // ❌ Wildcard resources
}
// ERROR: PolicyStatement has wildcard actions ('*') AND resources ('*').
//        This grants unrestricted access to ALL AWS services.

⚠️ WARNING: Individual Wildcards

FsCDK warns (but allows) single wildcards:

// This generates a compilation WARNING:
policyStatement {
    actions [ "*" ] // ⚠️ Warning: wildcard actions
    resources [ "arn:aws:s3:::my-bucket/*" ] // ✅ Specific resource
}

// This also generates a compilation WARNING:
policyStatement {
    actions [ "s3:GetObject"; "s3:PutObject" ] // ✅ Specific actions
    resources [ "*" ] // ⚠️ Warning: wildcard resources
}

✅ GOOD: Specific permissions

Grant only specific permissions needed (no warnings):

lambda "MyFunction" {
    runtime Runtime.DOTNET_8
    handler "MyApp::Handler"
    code "./publish"

    // Grant only specific permissions needed
    addRolePolicyStatements
        [ policyStatement {
              effect Effect.ALLOW
              actions [ "dynamodb:GetItem"; "dynamodb:PutItem" ]
              resources [ "arn:aws:dynamodb:us-east-1:123456789012:table/MyTable" ]
          }

          policyStatement {
              effect Effect.ALLOW
              actions [ "s3:GetObject" ]
              resources [ "arn:aws:s3:::my-bucket/*" ]
          } ]
}

Security Group Best Practices

FsCDK security groups follow least privilege by default.

open Amazon.CDK.AWS.EC2

// ✅ GOOD: FsCDK defaults to denying all outbound

stack "MyStack" {
    let! myVpc =
        vpc "MyVpc" {
            maxAzs 2
            natGateways 1
            cidr "10.0.0.0/16"
        }

    securityGroup "MySecurityGroup" {
        vpc myVpc
        description "Security group for Lambda"
        allowAllOutbound false // This is the default!
    }
}

Only allow specific outbound traffic (Note: In real code, you'd add ingress/egress rules after creation).

❌ BAD: Allowing all outbound unnecessarily:

stack "MyStack" {

    let! myVpc =
        vpc "MyVpc" {
            maxAzs 2
            natGateways 1
            cidr "10.0.0.0/16"
        }

    securityGroup "TooPermissive" {
        vpc myVpc
        allowAllOutbound true // Only use when absolutely necessary
    }
}

RDS Database Access

Restrict database access to specific security groups.

open Amazon.CDK.AWS.RDS

// ✅ GOOD: Database in private subnet with restricted access


stack "MyStack" {
    let! myVpc =
        vpc "MyVpc" {
            maxAzs 2
            natGateways 1
            cidr "10.0.0.0/16"
        }

    let! lambdaSecurityGroup =
        securityGroup "MySecurityGroup" {
            vpc myVpc
            description "Security group for Lambda"
            allowAllOutbound false // This is the default!
        }

    rdsInstance "MyDatabase" {
        vpc myVpc
        postgresEngine

        // Private subnet - not accessible from the internet
        vpcSubnets (SubnetSelection(SubnetType = SubnetType.PRIVATE_WITH_EGRESS))

        // Not publicly accessible
        publiclyAccessible false

        // Only Lambda security group can access
        securityGroup lambdaSecurityGroup

        // Enable IAM authentication for better security
        iamAuthentication true
    }
}

Cognito Security

Implement strong authentication and authorization.

open Amazon.CDK.AWS.Cognito

stack "MyStack" {
    // ✅ GOOD: Secure user pool configuration
    let! myUserPool =
        userPool "SecureUserPool" {
            signInWithEmail

            // Disable self sign-up to prevent unauthorized accounts
            selfSignUpEnabled false // Approve users manually or via API

            // Require MFA for sensitive operations
            mfa Mfa.REQUIRED

            // Strong password policy
            passwordPolicy (
                PasswordPolicy(
                    MinLength = 12,
                    RequireLowercase = true,
                    RequireUppercase = true,
                    RequireDigits = true,
                    RequireSymbols = true,
                    TempPasswordValidity = Duration.Days(7.0)
                )
            )

            // Account recovery via email only (more secure than SMS)
            accountRecovery AccountRecovery.EMAIL_ONLY
        }

    // ✅ GOOD: Secure client configuration
    userPoolClient "SecureClient" {
        userPool myUserPool

        // Don't generate secret for public clients (web/mobile)
        generateSecret false

        // Use SRP for secure authentication
        authFlows (
            AuthFlow(
                UserSrp = true,
                UserPassword = true,
                AdminUserPassword = false // Don't allow admin-initiated auth
            )
        )

        // Short-lived tokens
        tokenValidities (
            (Duration.Minutes 60.0), // refreshToken
            (Duration.Minutes 60.0), // accessToken
            (Duration.Days 30.0) // idToken
        )
    }
}

S3 Bucket Policies

Secure your S3 buckets properly.

open Amazon.CDK.AWS.S3

// ✅ GOOD: Secure S3 bucket
bucket "SecureAssets" {
    // Block all public access
    blockPublicAccess BlockPublicAccess.BLOCK_ALL

    // Encrypt data at rest
    encryption BucketEncryption.S3_MANAGED

    // Enforce SSL for all requests
    enforceSSL true

    // Enable versioning for data protection
    versioned true

    // Prevent accidental deletion
    removalPolicy RemovalPolicy.RETAIN
    autoDeleteObjects false
}

CloudFront CDN Security

Secure content delivery with CloudFront.

open Amazon.CDK.AWS.CloudFront

Common IAM Patterns

Read-Only Access to DynamoDB

lambda "ReadOnlyFunction" {
    runtime Runtime.DOTNET_8
    handler "MyApp::Handler"
    code "./publish"

    addRolePolicyStatement (
        policyStatement {
            effect Effect.ALLOW

            actions
                [ "dynamodb:GetItem"
                  "dynamodb:Query"
                  "dynamodb:Scan"
                  "dynamodb:BatchGetItem" ]

            resources [ "arn:aws:dynamodb:us-east-1:123456789012:table/MyTable" ]
        }
    )
}

Write Access to S3 Bucket

lambda "S3Writer" {
    runtime Runtime.DOTNET_8
    handler "MyApp::Handler"
    code "./publish"

    addRolePolicyStatement (
        policyStatement {
            effect Effect.ALLOW
            actions [ "s3:PutObject"; "s3:PutObjectAcl" ]
            resources [ "arn:aws:s3:::my-bucket/*" ]
        }
    )
}

Read from SQS Queue

open Amazon.CDK.AWS.SQS

lambda "QueueProcessor" {
    runtime Runtime.DOTNET_8
    handler "MyApp::Handler"
    code "./publish"

    addRolePolicyStatement (
        policyStatement {
            effect Effect.ALLOW
            actions [ "sqs:ReceiveMessage"; "sqs:DeleteMessage"; "sqs:GetQueueAttributes" ]
            resources [ "arn:aws:sqs:us-east-1:123456789012:my-queue" ]
        }
    )
}

Publish to SNS Topic

open Amazon.CDK.AWS.SNS

lambda "NotificationSender" {
    runtime Runtime.DOTNET_8
    handler "MyApp::Handler"
    code "./publish"

    addRolePolicyStatement (
        policyStatement {
            effect Effect.ALLOW
            actions [ "sns:Publish" ]
            resources [ "arn:aws:sns:us-east-1:123456789012:my-topic" ]
        }
    )
}

Virtual Private Cloud (VPC) Security

Network isolation and security.

// ✅ GOOD: Properly segmented VPC
vpc "SecureVpc" {
    maxAzs 2

    // Subnet configuration (done via CDK)
    // - Public subnets: NAT Gateways, Load Balancers
    // - Private subnets: Lambda, ECS, RDS
    // - Isolated subnets: Highly sensitive resources

    // NAT Gateways for private subnet internet access
    natGateways 2 // One per AZ for HA

// Enable VPC Flow Logs for monitoring
// (Note: Would need to be configured separately)
}

// Place sensitive resources in private subnets

stack "DatabaseStack" {
    let! myVpc =
        vpc "MyVpc" {
            maxAzs 2
            natGateways 1
            cidr "10.0.0.0/16"
        }

    let! lambdaSecurityGroup =
        securityGroup "MySecurityGroup" {
            vpc myVpc
            description "Security group for Lambda"
            allowAllOutbound false // This is the default!
        }

    rdsInstance "Database" {
        vpc myVpc
        postgresEngine
        vpcSubnets (SubnetSelection(SubnetType = SubnetType.PRIVATE_WITH_EGRESS))
        publiclyAccessible false
    }

    lambda "PrivateFunction" {
        runtime Runtime.DOTNET_8
        handler "MyApp::Handler"
        code "./publish"
        vpcSubnets (subnetSelection { subnetType SubnetType.PRIVATE_WITH_EGRESS })
        securityGroups [ lambdaSecurityGroup ]
    }
}

Monitoring and Auditing

Enable CloudTrail and monitoring.

// Enable detailed monitoring
lambda "MonitoredFunction" {
    runtime Runtime.DOTNET_8
    handler "MyApp::Handler"
    code "./publish"

    // Enable AWS X-Ray tracing
    tracing Tracing.ACTIVE

    // Enable Lambda Insights
    insightsVersion LambdaInsightsVersion.VERSION_1_0_229_0
}

// Enable RDS Performance Insights


stack "DatabaseStack" {
    let! myVpc =
        vpc "MyVpc" {
            maxAzs 2
            cidr "10.0.0.0/16"
        }

    rdsInstance "MonitoredDatabase" {
        vpc myVpc
        postgresEngine
        enablePerformanceInsights true
    }
}

Secrets Management

Never hardcode secrets!

❌ BAD: Hardcoded secrets

lambda "BadFunction" {
    runtime Runtime.DOTNET_8
    handler "MyApp::Handler"
    code "./publish"

    environment [ "DB_PASSWORD", "mypassword123" ] // Never do this!
}

✅ GOOD: Use Secrets Manager or Parameter Store

stack "DatabaseStack" {

    lambda "GoodFunction" {
        runtime Runtime.DOTNET_8
        handler "MyApp::Handler"
        code "./publish"

        environment [ "DB_SECRET_ARN", "arn:aws:secretsmanager:us-east-1:123456789012:secret:db-secret" ]

        // Grant permission to read secret
        addRolePolicyStatement (
            policyStatement {
                effect Effect.ALLOW
                actions [ "secretsmanager:GetSecretValue" ]
                resources [ "arn:aws:secretsmanager:us-east-1:123456789012:secret:db-secret" ]
            }
        )
    }

    let! myVpc =
        vpc "MyVpc" {
            maxAzs 2
            cidr "10.0.0.0/16"
        }

    // RDS can generate and manage secrets automatically
    rdsInstance "SecureDatabase" {
        vpc myVpc
        postgresEngine

        // Credentials automatically stored in Secrets Manager
        credentials (Credentials.FromGeneratedSecret "admin")
    }
}

Compliance Considerations

GDPR/Data Privacy

stack "DatabaseStack" {

    let! myVpc =
        vpc "MyVpc" {
            maxAzs 2
            cidr "10.0.0.0/16"
        }

    // Enable encryption for data at rest
    bucket "UserData" {
        encryption BucketEncryption.KMS_MANAGED // Customer managed keys
        blockPublicAccess BlockPublicAccess.BLOCK_ALL
    }

    rdsInstance "UserDatabase" {
        vpc myVpc
        postgresEngine
        storageEncrypted true
        deletionProtection true
    }

    // Enable audit logging
    userPool "CompliantUserPool" {
        signInWithEmail
    // Cognito automatically logs authentication events
    }
}

HIPAA/PHI Data

stack "DatabaseStack" {
    // Use KMS encryption for sensitive data
    bucket "HealthRecords" {
        encryption BucketEncryption.KMS_MANAGED
        versioned true
        removalPolicy RemovalPolicy.RETAIN
    }

    let! myVpc =
        vpc "MyVpc" {
            maxAzs 2
            cidr "10.0.0.0/16"
        }

    // Enable audit trails
    rdsInstance "HealthDatabase" {
        vpc myVpc
        postgresEngine
        storageEncrypted true
        backupRetentionDays 30.0 // Longer retention for compliance
        deletionProtection true
    }
}

OWASP Top 10 Applied to AWS Infrastructure

The OWASP Top 10 (https://owasp.org/www-project-top-ten/) defines critical web application security risks. Here's how they map to AWS infrastructure and FsCDK protections:

OWASP Risk

AWS Context

FsCDK Protection

A01: Broken Access Control

IAM too permissive, public S3

Blocks wildcard actions+resources, private S3 default

A02: Cryptographic Failures

Unencrypted data, no TLS

RDS/DynamoDB encryption enabled, HTTPS enforced

A03: Injection

SQL/command injection

IAM DB auth, parameterized queries, AWS WAF

A05: Security Misconfiguration

Public S3, open security groups

Secure defaults, deny-by-default security groups

A07: Broken Authentication

Weak passwords, no MFA

Cognito password policies, MFA enforcement

A08: Integrity Failures

Compromised packages

ECR image scanning, Lambda code signing

A09: Logging Failures

No CloudTrail/GuardDuty

X-Ray tracing, CloudWatch logs, audit trails

OWASP Serverless Top 10 for Lambda: 1. Injection flaws → validate inputs 2. Broken authentication → use Cognito authorizers 3. Sensitive data exposure → encrypt with KMS 4. Broken access control → IAM resource policies 5. Security misconfiguration → FsCDK secure defaults 6. Over-privileged permissions → FsCDK blocks wildcards 7. Inadequate logging → enable X-Ray tracing 8. Business logic manipulation → validate state transitions 9. Improper exception handling → don't leak secrets in errors 10. DoS attacks → use reserved concurrency limits

Reference: OWASP Serverless Top 10 (https://owasp.org/www-project-serverless-top-10/)

Operational Checklist

Use this before prod deploys (inspired by Piper's audits): 1. Validate policies with IAM Access Analyzer. 2. Enable MFA and rotate keys. 3. Scan for secrets with git-secrets. 4. Run Prowler for compliance. 5. Document all roles/policies.

Deliberate Practice Drills

Drill 1: Policy Crafting

  1. Write a policy allowing only S3:PutObject to a bucket.
  2. Test with Policy Simulator.
  3. Add conditions (e.g., IP restriction).

Drill 2: Privilege Escalation

  1. Use IAM Vulnerable to simulate attacks.
  2. Identify and fix escalations in sample policies.

📚 Learning Resources for IAM & AWS Security

AWS Official Documentation

IAM Fundamentals:

Security Best Practices:

AWS Heroes & Security Experts

Ben Kehoe (@ben11kehoe) - AWS Serverless Hero:

Scott Piper (@0xdabbad00) - AWS Security Hero:

Yan Cui (The Burning Monk) - Serverless Security:

IAM Deep Dives

Policy Evaluation Logic:

Least Privilege:

IAM Roles & Temporary Credentials:

Serverless Security

Lambda Security Best Practices:

API Gateway Security:

Secrets Management:

AWS Security Services

Detection & Response:

Compliance & Auditing:

Encryption & Key Management:

Security Frameworks & Compliance

Compliance Standards:

Security Frameworks:

Video Tutorials

IAM Fundamentals: - IAM Primer - AWS official introduction - Become an IAM Policy Master - Comprehensive tutorial - IAM Roles Explained - Understanding roles

Advanced Security:

Serverless Security:

Security Tools & Utilities

Policy Analysis:

Security Scanning:

Secrets Detection:

Hands-On Learning

AWS Security Workshops:

Security Challenges:

Recommended Learning Path

Week 1 - IAM Fundamentals:

  1. Read IAM User Guide - Chapters 1-5
  2. Watch IAM Primer Video
  3. Practice with IAM Policy Simulator
  4. Review FsCDK IAM examples (this document)

Week 2 - Policy Mastery:

  1. Study Policy Evaluation Logic
  2. Follow AWS Security Blog for latest IAM updates
  3. Use IAM Access Analyzer
  4. Take IAM Workshop

Week 3 - Security Services:

  1. Enable AWS GuardDuty
  2. Configure Security Hub
  3. Set up CloudTrail
  4. Run Prowler security scan

Week 4 - Serverless Security:

  1. Read Lambda Security Best Practices
  2. Implement Secrets Manager in Lambda
  3. Add Lambda authorizers to API Gateway
  4. Take Serverless Security Workshop

Ongoing - Security Mastery:

AWS Security Experts to Follow

AWS Heroes AWS Heroes and community experts who contribute to cloud security knowledge

AWS Heroes:

Security Researchers:

AWS Security Team:

Common Security Pitfalls

❌ DON'T:

  1. Use root account for daily tasks → Create IAM users with least privilege
  2. Hardcode AWS credentials → Use IAM roles for services, temporary credentials for users
  3. Use wildcard (*) in policies → Be specific with actions and resources
  4. Ignore CloudTrail logs → Enable and monitor for suspicious activity
  5. Share IAM credentials → Each person gets their own IAM user/role
  6. Leave unused access keys active → Rotate regularly, delete unused keys
  7. Grant broad S3 permissions → Use specific bucket and prefix restrictions
  8. Disable MFA → Enable MFA for all human users, especially admins

✅ DO:

  1. Use IAM roles for services → Lambda, EC2, ECS should use roles
  2. Enable MFA for all users → Especially for privileged accounts
  3. Rotate credentials regularly → 90-day rotation policy
  4. Use CloudTrail and Config → Audit all API calls and configuration changes
  5. Apply least privilege → Grant only necessary permissions
  6. Enable GuardDuty → Detect threats automatically
  7. Use Secrets Manager → Store and rotate secrets securely
  8. Tag resources → Enforce ABAC (Attribute-Based Access Control)

FsCDK Security Features

Security by Default:

IAM Helpers:

For implementation details, see src/IAM.fs and src/Grants.fs in the FsCDK repository.

Additional Security Resources

namespace FsCDK
namespace Amazon
namespace Amazon.CDK
namespace Amazon.CDK.AWS
namespace Amazon.CDK.AWS.Lambda
namespace Amazon.CDK.AWS.IAM
val lambda: name: string -> FunctionBuilder
<summary>Creates a Lambda function configuration.</summary>
<param name="name">The function name.</param>
<code lang="fsharp"> lambda "MyFunction" { handler "index.handler" runtime Runtime.NODEJS_18_X code "./lambda" timeout 30.0 } </code>
custom operation: runtime (Runtime) Calls FunctionBuilder.Runtime
<summary>Sets the runtime for the Lambda function.</summary>
<param name="config">The function configuration.</param>
<param name="runtime">The Lambda runtime.</param>
<code lang="fsharp"> lambda "MyFunction" { runtime Runtime.NODEJS_18_X } </code>
Multiple items
type Runtime = inherit DeputyBase new: name: string * ?family: Nullable<RuntimeFamily> * ?props: ILambdaRuntimeProps -> unit member RuntimeEquals: other: Runtime -> bool member ToString: unit -> string member BundlingImage: DockerImage member Family: Nullable<RuntimeFamily> member IsVariable: bool member Name: string member SupportsCodeGuruProfiling: bool member SupportsInlineCode: bool ...

--------------------
Runtime(name: string, ?family: System.Nullable<RuntimeFamily>, ?props: ILambdaRuntimeProps) : Runtime
property Runtime.DOTNET_8: Runtime with get
custom operation: handler (string) Calls FunctionBuilder.Handler
<summary>Sets the handler for the Lambda function.</summary>
<param name="config">The function configuration.</param>
<param name="handler">The handler name (e.g., "index.handler").</param>
<code lang="fsharp"> lambda "MyFunction" { handler "index.handler" } </code>
custom operation: code (Code) Calls FunctionBuilder.Code
<summary>Sets the code source from a Code object.</summary>
<param name="config">The function configuration.</param>
<param name="path">The Code object.</param>
<code lang="fsharp"> lambda "MyFunction" { code (Code.FromBucket myBucket "lambda.zip") } </code>
val myVpc: VpcSpec
val vpc: name: string -> VpcBuilder
<summary>Creates a VPC configuration with AWS best practices.</summary>
<param name="name">The VPC name.</param>
<code lang="fsharp"> vpc "MyVpc" { maxAzs 2 natGateways 1 cidr "10.0.0.0/16" } </code>
custom operation: maxAzs (int) Calls VpcBuilder.MaxAzs
<summary>Sets the maximum number of Availability Zones to use.</summary>
<param name="config">The current VPC configuration.</param>
<param name="maxAzs">The maximum number of AZs (default: 2 for HA).</param>
<code lang="fsharp"> vpc "MyVpc" { maxAzs 3 } </code>
custom operation: natGateways (int) Calls VpcBuilder.NatGateways
<summary>Sets the number of NAT Gateways.</summary>
<param name="config">The current VPC configuration.</param>
<param name="natGateways">The number of NAT gateways (default: 1 for cost optimization).</param>
<code lang="fsharp"> vpc "MyVpc" { natGateways 2 } </code>
custom operation: cidr (string) Calls VpcBuilder.Cidr
<summary>Sets the CIDR block for the VPC.</summary>
<param name="config">The current VPC configuration.</param>
<param name="cidr">The CIDR block (e.g., "10.0.0.0/16").</param>
<code lang="fsharp"> vpc "MyVpc" { cidr "10.0.0.0/16" } </code>
val policyStatement: PolicyStatementBuilder
custom operation: actions (string list) Calls PolicyStatementBuilder.Actions
custom operation: resources (string list) Calls PolicyStatementBuilder.Resources
custom operation: addRolePolicyStatements (PolicyStatement list) Calls FunctionBuilder.AddRolePolicyStatements
<summary>Sets the role policy statements list to the provided list (replaces existing).</summary>
<param name="config">The function configuration.</param>
<param name="statements">List of policy statements.</param>
<code lang="fsharp"> lambda "MyFunction" { addRolePolicyStatements [ stmt1; stmt2 ] } </code>
custom operation: effect (Effect) Calls PolicyStatementBuilder.Effect
[<Struct>] type Effect = | ALLOW = 0 | DENY = 1
field Effect.ALLOW: Effect = 0
namespace Amazon.CDK.AWS.EC2
val stack: name: string -> StackBuilder
<summary>Creates an AWS CDK Stack construct.</summary>
<param name="name">The name of the stack.</param>
<code lang="fsharp"> stack "MyStack" { lambda myFunction bucket myBucket } </code>
val myVpc: IVpc
val securityGroup: name: string -> SecurityGroupBuilder
<summary>Creates a Security Group configuration.</summary>
<param name="name">The Security Group name.</param>
<code lang="fsharp"> securityGroup "MySecurityGroup" { vpc myVpc description "Security group for my application" allowAllOutbound false } </code>
custom operation: vpc (IVpc) Calls SecurityGroupBuilder.Vpc
<summary>Sets the VPC for the Security Group.</summary>
<param name="config">The current Security Group configuration.</param>
<param name="vpc">The VPC.</param>
<code lang="fsharp"> securityGroup "MySecurityGroup" { vpc myVpc } </code>
custom operation: description (string) Calls SecurityGroupBuilder.Description
<summary>Sets the description for the Security Group.</summary>
<param name="config">The current Security Group configuration.</param>
<param name="description">The description.</param>
<code lang="fsharp"> securityGroup "MySecurityGroup" { description "Security group for my application" } </code>
custom operation: allowAllOutbound (bool) Calls SecurityGroupBuilder.AllowAllOutbound
<summary>Sets whether to allow all outbound traffic.</summary>
<param name="config">The current Security Group configuration.</param>
<param name="allow">Whether to allow all outbound (default: false for least privilege).</param>
<code lang="fsharp"> securityGroup "MySecurityGroup" { allowAllOutbound true } </code>
namespace Amazon.CDK.AWS.RDS
val lambdaSecurityGroup: ISecurityGroup
val rdsInstance: name: string -> DatabaseInstanceBuilder
<summary>Creates an RDS Database Instance with AWS best practices.</summary>
<param name="name">The database instance name.</param>
<code lang="fsharp"> rdsInstance "MyDatabase" { vpc myVpc postgresEngine PostgresEngineVersion.VER_15 instanceType (InstanceType.Of(InstanceClass.BURSTABLE3, InstanceSize.SMALL)) multiAz true backupRetentionDays 7.0 } </code>
custom operation: vpc (IVpc) Calls DatabaseInstanceBuilder.Vpc
<summary>Sets the VPC.</summary>
custom operation: postgresEngine (PostgresEngineVersion option) Calls DatabaseInstanceBuilder.PostgresEngine
<summary>Sets PostgreSQL as the database engine with a specific version.</summary>
custom operation: vpcSubnets (SubnetSelection) Calls DatabaseInstanceBuilder.VpcSubnets
<summary>Sets the VPC subnets.</summary>
Multiple items
type SubnetSelection = interface ISubnetSelection new: unit -> unit member AvailabilityZones: string array member OnePerAz: Nullable<bool> member SubnetFilters: SubnetFilter array member SubnetGroupName: string member SubnetType: Nullable<SubnetType> member Subnets: ISubnet array

--------------------
SubnetSelection() : SubnetSelection
[<Struct>] type SubnetType = | PRIVATE_ISOLATED = 0 | PRIVATE_WITH_EGRESS = 1 | PRIVATE_WITH_NAT = 2 | PUBLIC = 3
field SubnetType.PRIVATE_WITH_EGRESS: SubnetType = 1
custom operation: publiclyAccessible (bool) Calls DatabaseInstanceBuilder.PubliclyAccessible
<summary>Sets whether the database is publicly accessible.</summary>
custom operation: securityGroup (ISecurityGroup) Calls DatabaseInstanceBuilder.SecurityGroup
<summary>Adds a security group.</summary>
custom operation: iamAuthentication (bool) Calls DatabaseInstanceBuilder.IamAuthentication
<summary>Enables IAM authentication.</summary>
namespace Amazon.CDK.AWS.Cognito
val myUserPool: IUserPool
val userPool: name: string -> UserPoolBuilder
<summary>Creates a Cognito User Pool with AWS best practices.</summary>
<param name="name">The user pool name.</param>
<code lang="fsharp"> userPool "MyUserPool" { signInWithEmail selfSignUpEnabled true mfa Mfa.OPTIONAL } </code>
custom operation: signInWithEmail Calls UserPoolBuilder.SignInWithEmail
<summary>Enables email only as sign-in alias.</summary>
custom operation: selfSignUpEnabled (bool) Calls UserPoolBuilder.SelfSignUpEnabled
<summary>Enables or disables self sign-up.</summary>
custom operation: mfa (Mfa) Calls UserPoolBuilder.Mfa
<summary>Sets MFA configuration.</summary>
[<Struct>] type Mfa = | OFF = 0 | OPTIONAL = 1 | REQUIRED = 2
field Mfa.REQUIRED: Mfa = 2
custom operation: passwordPolicy (IPasswordPolicy) Calls UserPoolBuilder.PasswordPolicy
<summary>Sets password policy.</summary>
Multiple items
type PasswordPolicy = interface IPasswordPolicy new: unit -> unit member MinLength: Nullable<float> member PasswordHistorySize: Nullable<float> member RequireDigits: Nullable<bool> member RequireLowercase: Nullable<bool> member RequireSymbols: Nullable<bool> member RequireUppercase: Nullable<bool> member TempPasswordValidity: Duration

--------------------
PasswordPolicy() : PasswordPolicy
type Duration = inherit DeputyBase member FormatTokenToNumber: unit -> string member IsUnresolved: unit -> bool member Minus: rhs: Duration -> Duration member Plus: rhs: Duration -> Duration member ToDays: ?opts: ITimeConversionOptions -> float member ToHours: ?opts: ITimeConversionOptions -> float member ToHumanString: unit -> string member ToIsoString: unit -> string member ToMilliseconds: ?opts: ITimeConversionOptions -> float ...
Duration.Days(amount: float) : Duration
custom operation: accountRecovery (AccountRecovery) Calls UserPoolBuilder.AccountRecovery
<summary>Sets account recovery method.</summary>
[<Struct>] type AccountRecovery = | EMAIL_AND_PHONE_WITHOUT_MFA = 0 | PHONE_WITHOUT_MFA_AND_EMAIL = 1 | EMAIL_ONLY = 2 | PHONE_ONLY_WITHOUT_MFA = 3 | PHONE_AND_EMAIL = 4 | NONE = 5
field AccountRecovery.EMAIL_ONLY: AccountRecovery = 2
val userPoolClient: name: string -> UserPoolClientBuilder
<summary>Creates a Cognito User Pool Client.</summary>
<param name="name">The client name.</param>
<code lang="fsharp"> userPoolClient "MyAppClient" { userPool myUserPool generateSecret false } </code>
custom operation: userPool (IUserPool) Calls UserPoolClientBuilder.UserPool
<summary>Sets the user pool.</summary>
custom operation: generateSecret (bool) Calls UserPoolClientBuilder.GenerateSecret
<summary>Enables or disables secret generation.</summary>
custom operation: authFlows (IAuthFlow) Calls UserPoolClientBuilder.AuthFlows
<summary>Sets authentication flows.</summary>
Multiple items
type AuthFlow = interface IAuthFlow new: unit -> unit member AdminUserPassword: Nullable<bool> member Custom: Nullable<bool> member User: Nullable<bool> member UserPassword: Nullable<bool> member UserSrp: Nullable<bool>

--------------------
AuthFlow() : AuthFlow
custom operation: tokenValidities (Duration * Duration * Duration) Calls UserPoolClientBuilder.TokenValidities
<summary>Sets token validities.</summary>
Duration.Minutes(amount: float) : Duration
namespace Amazon.CDK.AWS.S3
val bucket: name: string -> BucketBuilder
custom operation: blockPublicAccess (BlockPublicAccess) Calls BucketBuilder.BlockPublicAccess
Multiple items
type BlockPublicAccess = inherit DeputyBase new: options: IBlockPublicAccessOptions -> unit member BlockPublicAcls: Nullable<bool> member BlockPublicPolicy: Nullable<bool> member IgnorePublicAcls: Nullable<bool> member RestrictPublicBuckets: Nullable<bool> static member BLOCK_ACLS: BlockPublicAccess static member BLOCK_ACLS_ONLY: BlockPublicAccess static member BLOCK_ALL: BlockPublicAccess

--------------------
BlockPublicAccess(options: IBlockPublicAccessOptions) : BlockPublicAccess
property BlockPublicAccess.BLOCK_ALL: BlockPublicAccess with get
custom operation: encryption (BucketEncryption) Calls BucketBuilder.Encryption
[<Struct>] type BucketEncryption = | UNENCRYPTED = 0 | KMS_MANAGED = 1 | S3_MANAGED = 2 | KMS = 3 | DSSE_MANAGED = 4 | DSSE = 5
field BucketEncryption.S3_MANAGED: BucketEncryption = 2
custom operation: enforceSSL (bool) Calls BucketBuilder.EnforceSSL
custom operation: versioned (bool) Calls BucketBuilder.Versioned
<summary> Enables or disables versioning for the S3 bucket. **Security Best Practice:** Enable versioning for: - Critical data that requires audit trails - Data subject to compliance requirements (HIPAA, SOC2, etc.) - Production buckets storing business data **Cost Consideration:** Versioning stores all versions of objects, increasing storage costs. Only disable for: - Temporary/cache buckets - Build artifacts with short lifecycle - Development/testing buckets **Default:** false (opt-in for cost optimization) </summary>
<param name="value">True to enable versioning, false to disable.</param>
<param name="config">The current bucket configuration.</param>
<code lang="fsharp"> bucket "production-data" { versioned true // Enable for production } bucket "cache-bucket" { versioned false // Disable for temp data } </code>
custom operation: removalPolicy (RemovalPolicy) Calls BucketBuilder.RemovalPolicy
[<Struct>] type RemovalPolicy = | DESTROY = 0 | RETAIN = 1 | SNAPSHOT = 2 | RETAIN_ON_UPDATE_OR_DELETE = 3
field RemovalPolicy.RETAIN: RemovalPolicy = 1
custom operation: autoDeleteObjects (bool) Calls BucketBuilder.AutoDeleteObjects
namespace Amazon.CDK.AWS.CloudFront
val myBehavior: IBehaviorOptions
module CloudFrontBehaviors from FsCDK
<summary> Factory helpers to build common IBehaviorOptions for S3 and HTTP origins. These helpers are useful if you prefer to construct behaviors and pass them via defaultBehavior/additionalBehavior. </summary>
val httpBehaviorDefault: domainName: string -> (bool option -> IBehaviorOptions)
union case Option.Some: Value: 'T -> Option<'T>
val myLogBucket: IBucket
val cloudFrontDistribution: name: string -> DistributionBuilder
<summary>Creates a CloudFront distribution with AWS best practices.</summary>
<param name="name">The distribution name.</param>
<remarks> Example: cloudFrontDistribution "MyCDN" { s3DefaultBehavior myBucket defaultRootObject "index.html" domainName "static.example.com" priceClass PriceClass.PRICE_CLASS_100 } </remarks>
custom operation: defaultBehavior (IBehaviorOptions) Calls DistributionBuilder.DefaultBehavior
<summary>Sets the default behavior from a pre-built IBehaviorOptions.</summary>
custom operation: minimumProtocolVersion (SecurityPolicyProtocol) Calls DistributionBuilder.MinimumProtocolVersion
<summary>Sets the minimum TLS protocol version.</summary>
[<Struct>] type SecurityPolicyProtocol = | SSL_V3 = 0 | TLS_V1 = 1 | TLS_V1_2016 = 2 | TLS_V1_1_2016 = 3 | TLS_V1_2_2018 = 4 | TLS_V1_2_2019 = 5 | TLS_V1_2_2021 = 6
field SecurityPolicyProtocol.TLS_V1_2_2021: SecurityPolicyProtocol = 6
custom operation: enableLogging (IBucket) (string option) (bool option) Calls DistributionBuilder.EnableLogging
<summary>Enables logging to an S3 bucket (optionally with a prefix and cookies flag).</summary>
custom operation: addRolePolicyStatement (PolicyStatement) Calls FunctionBuilder.AddRolePolicyStatement
<summary>Adds a single role policy statement.</summary>
<param name="config">The function configuration.</param>
<param name="statements">Policy statement.</param>
<code lang="fsharp"> lambda "MyFunction" { addRolePolicyStatement stmt } </code>
namespace Amazon.CDK.AWS.SQS
namespace Amazon.CDK.AWS.SNS
custom operation: vpcSubnets (ISubnetSelection) Calls FunctionBuilder.VpcSubnets
<summary>Specifies which subnets in the VPC the function should use.</summary>
<param name="config">The function configuration.</param>
<param name="subnets">Subnet selection.</param>
<code lang="fsharp"> lambda "MyFunction" { vpcSubnets (SubnetSelection.SubnetType SubnetType.PRIVATE_WITH_EGRESS) } </code>
val subnetSelection: SubnetSelectionBuilder
custom operation: subnetType (SubnetType) Calls SubnetSelectionBuilder.SubnetType
custom operation: securityGroups (ISecurityGroup list) Calls FunctionBuilder.SecurityGroups
<summary>Adds one or more security groups to the function's network configuration.</summary>
<param name="config">The function configuration.</param>
<param name="sgs">List of security groups.</param>
<code lang="fsharp"> lambda "MyFunction" { securityGroups [ sgA; sgB ] } </code>
custom operation: tracing (Tracing) Calls FunctionBuilder.Tracing
<summary>Sets the tracing mode for AWS X-Ray.</summary>
<param name="config">The function configuration.</param>
<param name="tracing">Tracing mode (e.g., ACTIVE, PASS_THROUGH).</param>
<code lang="fsharp"> lambda "MyFunction" { tracing Tracing.ACTIVE } </code>
[<Struct>] type Tracing = | ACTIVE = 0 | PASS_THROUGH = 1 | DISABLED = 2
field Tracing.ACTIVE: Tracing = 0
custom operation: insightsVersion (LambdaInsightsVersion) Calls FunctionBuilder.InsightsVersion
<summary>Sets the Lambda Insights version to enable enhanced monitoring.</summary>
<param name="config">The function configuration.</param>
<param name="version">Insights layer version.</param>
<code lang="fsharp"> lambda "MyFunction" { insightsVersion LambdaInsightsVersion.VERSION_1_0_135_0 } </code>
type LambdaInsightsVersion = inherit DeputyBase static member FromInsightVersionArn: arn: string -> LambdaInsightsVersion member LayerVersionArn: string static member VERSION_1_0_119_0: LambdaInsightsVersion static member VERSION_1_0_135_0: LambdaInsightsVersion static member VERSION_1_0_143_0: LambdaInsightsVersion static member VERSION_1_0_178_0: LambdaInsightsVersion static member VERSION_1_0_229_0: LambdaInsightsVersion static member VERSION_1_0_273_0: LambdaInsightsVersion static member VERSION_1_0_275_0: LambdaInsightsVersion ...
property LambdaInsightsVersion.VERSION_1_0_229_0: LambdaInsightsVersion with get
custom operation: enablePerformanceInsights (bool) Calls DatabaseInstanceBuilder.EnablePerformanceInsights
<summary>Enables performance insights.</summary>
custom operation: environment ((string * string) list) Calls FunctionBuilder.Environment
<summary>Sets environment variables for the Lambda function.</summary>
<param name="config">The function configuration.</param>
<param name="env">List of key-value pairs for environment variables.</param>
<code lang="fsharp"> lambda "MyFunction" { environment [ "KEY1", "value1"; "KEY2", "value2" ] } </code>
custom operation: credentials (Credentials) Calls DatabaseInstanceBuilder.Credentials
<summary>Sets the credentials.</summary>
type Credentials = inherit DeputyBase static member FromGeneratedSecret: username: string * ?options: ICredentialsBaseOptions -> Credentials static member FromPassword: username: string * password: SecretValue -> Credentials static member FromSecret: secret: ISecret * ?username: string -> Credentials static member FromUsername: username: string * ?options: ICredentialsFromUsernameOptions -> Credentials member EncryptionKey: IKey member ExcludeCharacters: string member Password: SecretValue member ReplicaRegions: IReplicaRegion array member Secret: ISecret ...
Credentials.FromGeneratedSecret(username: string, ?options: ICredentialsBaseOptions) : Credentials
field BucketEncryption.KMS_MANAGED: BucketEncryption = 1
custom operation: storageEncrypted (bool) Calls DatabaseInstanceBuilder.StorageEncrypted
<summary>Enables storage encryption.</summary>
custom operation: deletionProtection (bool) Calls DatabaseInstanceBuilder.DeletionProtection
<summary>Enables or disables deletion protection.</summary>
custom operation: backupRetentionDays (float) Calls DatabaseInstanceBuilder.BackupRetentionDays
<summary>Sets the backup retention period in days.</summary>

Type something to start searching.